Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix endpoint api/users/reset-password to set tenant ID. #742

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove tenant param from ResetPasswordAsync interface; Add TennantIdH…
…eader to ResetPasswordAsync method; Update message in ForgotPasswordAsync;
  • Loading branch information
jay-cascade committed Jul 14, 2022
commit 2d7d608fe2f56f96bfb8eb080b34e6c9263ae0a3
2 changes: 1 addition & 1 deletion src/Core/Application/Identity/Users/IUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ public interface IUserService : ITransientService
Task<string> ConfirmPhoneNumberAsync(string userId, string code);

Task<string> ForgotPasswordAsync(ForgotPasswordRequest request, string origin);
Task<string> ResetPasswordAsync(ResetPasswordRequest request, string tenant);
Task<string> ResetPasswordAsync(ResetPasswordRequest request);
Task ChangePasswordAsync(ChangePasswordRequest request, string userId);
}
5 changes: 3 additions & 2 deletions src/Host/Controllers/Identity/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ public Task<string> ForgotPasswordAsync(ForgotPasswordRequest request)

[HttpPost("reset-password")]
[AllowAnonymous]
[TenantIdHeader]
[OpenApiOperation("Reset a user's password.", "")]
[ApiConventionMethod(typeof(FSHApiConventions), nameof(FSHApiConventions.Register))]
public Task<string> ResetPasswordAsync(ResetPasswordRequest request, [FromQuery] string tenant)
public Task<string> ResetPasswordAsync(ResetPasswordRequest request)
{
return _userService.ResetPasswordAsync(request, tenant);
return _userService.ResetPasswordAsync(request);
}

private string GetOriginFromRequest() => $"{Request.Scheme}://{Request.Host.Value}{Request.PathBase.Value}";
Expand Down
4 changes: 2 additions & 2 deletions src/Infrastructure/Identity/UserService.Password.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public async Task<string> ForgotPasswordAsync(ForgotPasswordRequest request, str
// For more information on how to enable account confirmation and password reset please
// visit https://go.microsoft.com/fwlink/?LinkID=532713
string code = await _userManager.GeneratePasswordResetTokenAsync(user);
string route = $"account/reset-password?token={code}";
const string route = $"account/reset-password";
var endpointUri = new Uri(string.Concat($"{origin}/", route));
string passwordResetUrl = QueryHelpers.AddQueryString(endpointUri.ToString(), "Token", code);
var mailRequest = new MailRequest(
Expand All @@ -33,7 +33,7 @@ public async Task<string> ForgotPasswordAsync(ForgotPasswordRequest request, str
return _t["Password Reset Mail has been sent to your authorized Email."];
}

public async Task<string> ResetPasswordAsync(ResetPasswordRequest request, string tenant)
public async Task<string> ResetPasswordAsync(ResetPasswordRequest request)
{
EnsureValidTenant();

Expand Down