public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { User user = await _userManager.FindUserByUsernameOrEmailAsync(request.UsernameOrEmail); var token = await _userManager.GeneratePasswordResetTokenAsync(user); var param = new Dictionary <string, string> { { "token", token }, { "email", user.Email } }; var uri = QueryHelpers.AddQueryString(request.ClientUri, param); var template = new ResetPasswordTemplate { DisplayName = user.DisplayName, ArpaLogo = $"{_jwtConfiguration.Audience}/images/arpa_logo.png", ClientUri = uri, ClubAddress = _clubConfiguration.Address, ClubMail = _clubConfiguration.Email, ClubName = _clubConfiguration.Name, ClubPhoneNumber = _clubConfiguration.Phone }; await _emailSender.SendTemplatedEmailAsync(template, user.Email); return(Unit.Value); }
public ViewResult ForgotPassword(ForgotPasswordViewModel command) { var template = new ResetPasswordTemplate(); _authenticationHelper.SendPasswordResetNotification(this, command, template, new CofoundryAdminUserArea()); return(View(command)); }
public async Task <ViewResult> ForgotPassword(ForgotPasswordViewModel command) { var template = new ResetPasswordTemplate(); await _authenticationHelper.SendPasswordResetNotificationAsync(this, command, template, new CofoundryAdminUserArea()); var viewPath = ViewPathFormatter.View(CONTROLLER_NAME, nameof(ForgotPassword)); return(View(viewPath, command)); }
public async Task <ViewResult> ForgotPassword(ForgotPasswordViewModel command) { var template = new ResetPasswordTemplate(); var settings = await _queryExecutor.ExecuteAsync(new GetSettingsQuery <GeneralSiteSettings>()); template.ApplicationName = settings.ApplicationName; await _authenticationHelper.SendPasswordResetNotificationAsync(this, command, template, _adminUserArea); var viewPath = ViewPathFormatter.View(CONTROLLER_NAME, nameof(ForgotPassword)); return(View(viewPath, command)); }
// By email, send token and guid public async Task SendResetPasswordMail(string email) { // Prepare mail var guid = new Guid(); string link = $"{guid}"; int shortCode = generatorService.Generate(); // configure mail var resetPasswordTemplate = new ResetPasswordTemplate(); resetPasswordTemplate.Configure(shortCode, link); // send email await emailTemplateSender.SendMailAsync(email, resetPasswordTemplate); // save request await emailVerifierRepository.CreateEmailVerifier(0, email, shortCode, guid); }
public async Task SendResetPassword(SendResetPasswordRequest request) { var resetToken = string.Empty; UserEntity user; using (var uow = _uowFactory.GetUnitOfWork()) { user = await uow.UserRepo.GetUserById(new Repositories.DatabaseRepos.UserRepo.Models.GetUserByIdRequest() { Id = request.UserId }); resetToken = GenerateUniqueUserToken(uow); await uow.UserRepo.CreateUserToken(new Repositories.DatabaseRepos.UserRepo.Models.CreateUserTokenRequest() { User_Id = request.UserId, Token = new Guid(resetToken), Type_Id = (int)TokenTypeEnum.ResetPassword, Created_By = ApplicationConstants.SystemUserId, }); uow.Commit(); } var configuration = await _cache.Configuration(); var baseUrl = _httpContextAccessor.HttpContext.Request.GetBaseUrl(); var templateHtml = await _emailTemplateRepo.GetForgotPasswordHTML(); var template = new ResetPasswordTemplate(templateHtml) { ResetPasswordUrl = $"{baseUrl}/reset-password?token={resetToken}", ApplicationUrl = baseUrl }; await _emailProvider.Send(new Infrastructure.Email.Models.SendRequest() { FromAddress = configuration.System_From_Email_Address, ToAddress = user.Email_Address, Subject = template.Subject, Body = template.GetHTMLContent() }); }