Browse Source

Merge pull request #9277 from abpframework/liangshiwei/account

Change current tenant when reset password
pull/9292/head
maliming 5 years ago
committed by GitHub
parent
commit
e9e6540b3e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/ResetPasswordDto.cs
  2. 19
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs
  3. 8
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/ResetPassword.cshtml.cs

2
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/ResetPasswordDto.cs

@ -8,6 +8,8 @@ namespace Volo.Abp.Account
{
public Guid UserId { get; set; }
public Guid? TenantId { get; set; }
[Required]
public string ResetToken { get; set; }

19
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/AccountAppService.cs

@ -62,16 +62,19 @@ namespace Volo.Abp.Account
public virtual async Task ResetPasswordAsync(ResetPasswordDto input)
{
await IdentityOptions.SetAsync();
using (CurrentTenant.Change(input.TenantId))
{
await IdentityOptions.SetAsync();
var user = await UserManager.GetByIdAsync(input.UserId);
(await UserManager.ResetPasswordAsync(user, input.ResetToken, input.Password)).CheckErrors();
var user = await UserManager.GetByIdAsync(input.UserId);
(await UserManager.ResetPasswordAsync(user, input.ResetToken, input.Password)).CheckErrors();
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = IdentitySecurityLogActionConsts.ChangePassword
});
await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = IdentitySecurityLogActionConsts.ChangePassword
});
}
}
protected virtual async Task<IdentityUser> GetUserByEmail(string email)

8
modules/account/src/Volo.Abp.Account.Web/Pages/Account/ResetPassword.cshtml.cs

@ -58,8 +58,6 @@ namespace Volo.Abp.Account.Web.Pages.Account
public virtual Task<IActionResult> OnGetAsync()
{
//TODO: It would be good to try to switch tenant if needed
CheckCurrentTenant(TenantId);
return Task.FromResult<IActionResult>(Page());
}
@ -74,7 +72,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
{
UserId = UserId,
ResetToken = ResetToken,
Password = Password
Password = Password,
TenantId = TenantId
}
);
}
@ -101,7 +100,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
{
if (!Equals(Password, ConfirmPassword))
{
ModelState.AddModelError("ConfirmPassword", L["'{0}' and '{1}' do not match.", "ConfirmPassword", "Password"]);
ModelState.AddModelError("ConfirmPassword",
L["'{0}' and '{1}' do not match.", "ConfirmPassword", "Password"]);
}
base.ValidateModel();

Loading…
Cancel
Save