예제 #1
0
        public async Task SendResetPasswordLink(Account account, CancellationToken cancellationToken)
        {
            if (account.ResetPasswordTokenGenerationTime == null ||
                account.ResetPasswordTokenGenerationTime.Value.Add(_resetPasswordOptions.ExpiresAfter) <
                DateTime.UtcNow)
            {
                account.ResetPasswordToken = VerificationHelper.GenerateEmailToken();
                account.ResetPasswordTokenGenerationTime = DateTime.UtcNow;
            }

            await _accountManager.SaveAsync(account, cancellationToken);

            var url   = string.Format(_resetPasswordOptions.LinkFormat, account.Id, account.ResetPasswordToken);
            var title = account.Email;

            await SendEmailAsync(account.Email, _stringLocalizer["ResetPassword.Subject"],
                                 string.Format(_stringLocalizer["ResetPassword.Body"], url), cancellationToken);
        }