Skip to content

Commit

Permalink
implement PasswordResetToken
Browse files Browse the repository at this point in the history
  • Loading branch information
imaun committed Aug 31, 2023
1 parent 7b243af commit 09e8014
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Idyfa.Core/Services/IdyfaAuthManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,25 @@ public async Task ConfirmEmailAsync(string userName, string token)
throw new IdyfaInvalidEmailTokenException();
}

public Task<string> GenerateResetPasswordTokenAsync(string userName)
public async Task<string> GenerateResetPasswordTokenAsync(string userName)
{
throw new NotImplementedException();
if (userName.IsNullOrEmpty())
throw new ArgumentNullException(nameof(userName));

if (GetUserNameType() == UserNameType.PhoneNumber)
{
userName = userName.NormalizePhoneNumber();
}

var validateUsername = _userValidator.ValidateUserName(userName);
if (validateUsername.Any())
throw new InvalidUserNameException(validateUsername);

var user = await _userManager.FindByUserNameAsync(userName).ConfigureAwait(false);
if (user is null) throw new IdyfaUserNotFoundException();

var token = await _userManager.GeneratePasswordResetTokenAsync(user).ConfigureAwait(false);
return await Task.FromResult(token);
}

public Task<bool> VerifyResetPasswordTokenAsync(string userName, string token)
Expand Down

0 comments on commit 09e8014

Please sign in to comment.