Browse Source

🐛 fix: 修复邮件确认链接某些编码问题.

pull/1082/head
colin 1 year ago
parent
commit
d5b1650e5e
  1. 4
      aspnet-core/framework/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN/Abp/SettingManagement/Dto/ValueType.cs
  2. 2
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs
  3. 10
      aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs
  4. 2
      aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs

4
aspnet-core/framework/settings/LINGYUN.Abp.SettingManagement.Application.Contracts/LINGYUN/Abp/SettingManagement/Dto/ValueType.cs

@ -2,6 +2,10 @@
public enum ValueType public enum ValueType
{ {
/// <summary>
/// 不加入设置管理(配合前端请勿传递设置值)
/// </summary>
NoSet = -1,
/// <summary> /// <summary>
/// 字符 /// 字符
/// </summary> /// </summary>

2
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/Emailing/AccountEmailSender.cs

@ -66,7 +66,7 @@ public class AccountEmailSender :
var url = await AppUrlProvider.GetUrlAsync(appName, AccountUrlNames.EmailConfirm); var url = await AppUrlProvider.GetUrlAsync(appName, AccountUrlNames.EmailConfirm);
var link = $"{url}?userId={user.Id}&{TenantResolverConsts.DefaultTenantKey}={user.TenantId}&confirmToken={UrlEncoder.Default.Encode(confirmToken)}"; var link = $"{url}?userId={user.Id}&{TenantResolverConsts.DefaultTenantKey}={user.TenantId}&confirmToken={confirmToken}";
if (!returnUrl.IsNullOrEmpty()) if (!returnUrl.IsNullOrEmpty())
{ {

10
aspnet-core/modules/account/LINGYUN.Abp.Account.Application/LINGYUN/Abp/Account/MyProfileAppService.cs

@ -9,8 +9,11 @@ using Microsoft.Extensions.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Net;
using System.Text; using System.Text;
using System.Text.Encodings.Web;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Account.Localization; using Volo.Abp.Account.Localization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
@ -165,11 +168,12 @@ public class MyProfileAppService : AccountApplicationServiceBase, IMyProfileAppS
} }
var token = await UserManager.GenerateEmailConfirmationTokenAsync(user); var token = await UserManager.GenerateEmailConfirmationTokenAsync(user);
var confirmToken = WebUtility.UrlEncode(token);
var sender = LazyServiceProvider.LazyGetRequiredService<IAccountEmailConfirmSender>(); var sender = LazyServiceProvider.LazyGetRequiredService<IAccountEmailConfirmSender>();
await sender.SendEmailConfirmLinkAsync( await sender.SendEmailConfirmLinkAsync(
user, user,
token, confirmToken,
input.AppName, input.AppName,
input.ReturnUrl, input.ReturnUrl,
input.ReturnUrlHash); input.ReturnUrlHash);
@ -181,7 +185,9 @@ public class MyProfileAppService : AccountApplicationServiceBase, IMyProfileAppS
var user = await UserManager.GetByIdAsync(CurrentUser.GetId()); var user = await UserManager.GetByIdAsync(CurrentUser.GetId());
(await UserManager.ConfirmEmailAsync(user, input.ConfirmToken)).CheckErrors(); // 字符编码错误
var confirmToken = WebUtility.UrlDecode(input.ConfirmToken.Replace("%20", "%2B"));
(await UserManager.ConfirmEmailAsync(user, confirmToken)).CheckErrors();
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
{ {

2
aspnet-core/modules/settings/LINGYUN.Abp.SettingManagement.Application/LINGYUN/Abp/SettingManagement/SettingAppService.cs

@ -477,7 +477,7 @@ public class SettingAppService : ApplicationService, ISettingAppService, ISettin
description: LocalizableString.Create<AbpSettingManagementResource>("Description:Emailing.SendTestEmail")), description: LocalizableString.Create<AbpSettingManagementResource>("Description:Emailing.SendTestEmail")),
StringLocalizerFactory, StringLocalizerFactory,
"", "",
ValueType.String, ValueType.NoSet,
providerName) providerName)
.WithSlot("send-test-email") .WithSlot("send-test-email")
.RequiredPermission("SettingManagement.Emailing"); .RequiredPermission("SettingManagement.Emailing");

Loading…
Cancel
Save