Skip to content

Commit

Permalink
implement GenerateEmailConfirmToken
Browse files Browse the repository at this point in the history
  • Loading branch information
imaun committed Aug 31, 2023
1 parent f67cca6 commit f53e8ac
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/Idyfa.Core/Services/IdyfaAuthManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,24 @@ public Task RegisterUserAsync(
throw new NotImplementedException();
}

public Task<string> GenerateEmailConfirmationTokenAsync(string userName)
public async Task<string> GenerateEmailConfirmationTokenAsync(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.FindByNameAsync(userName).ConfigureAwait(false);
if (user is null) throw new IdyfaUserNotFoundException();

return await _userManager.GenerateEmailConfirmationTokenAsync(user).ConfigureAwait(false);
}

public Task ConfirmEmailAsync(string userName, string token)
Expand Down

0 comments on commit f53e8ac

Please sign in to comment.