public async Task <EmailConfirmationResult> ActivateUserAccountAsync(ConfirmEmailTokenDto confirmEmailTokenDto) { EmailConfirmationResult returnResult = new EmailConfirmationResult { OperationResult = new OperationResult() }; try { var user = await _userManager.FindByIdAsync(confirmEmailTokenDto.UserId); if (user == null) { throw new YawnMassageException("ERROR_NO_USER_FOUND"); } //activate user var result = await _userManager.ConfirmEmailAsync(user, confirmEmailTokenDto.EmailConfirmationToken); if (result.Succeeded) { //password reset token var passwordResetToken = await _userManager.GeneratePasswordResetTokenAsync(user); string encodedPasswordResetToken = WebUtility.UrlEncode(passwordResetToken); returnResult.PasswordResetToken = encodedPasswordResetToken; returnResult.Email = user.Email; returnResult.OperationResult.IsSuccess = true; } else { returnResult.OperationResult.IsSuccess = false; returnResult.OperationResult.Message = "ERROR_INVALID_ACTIVATION_LINK"; } } catch (Exception ex) { returnResult.OperationResult.IsSuccess = false; returnResult.OperationResult.Message = ex.Message; } return(returnResult); }
public async Task <EmailConfirmationResult> ConfirmUserEmail([FromBody] ConfirmEmailTokenDto confirmEmailTokenDto) { return(await _identityService.ActivateUserAccountAsync(confirmEmailTokenDto)); }
public Task <EmailConfirmationResult> ActivateUserAccountAsync(ConfirmEmailTokenDto confirmEmailTokenDto) { throw new NotImplementedException(); }