/// <summary> /// Sends the given user a new verify email link /// </summary> /// <param name="user">The user to send the link to</param> /// <returns></returns> private async Task SendUserEmailVerificationAsync(ApplicationUser user) { // Generate an email verification code var emailVerificationCode = await mUserManager.GenerateEmailConfirmationTokenAsync(user); //Set the URL of the Api client that will verify the user var confirmationUrl = $"{Framework.Construction.Configuration["Client:Host"]}/email-verified/{HttpUtility.UrlEncode(user.Id)}/{HttpUtility.UrlEncode(emailVerificationCode)}"; // Email the user the verification code await LoremIpsumEmailSender.SendUserVerificationEmailAsync(user.Employee.FirstName, user.Email, confirmationUrl); }
public async Task <ApiResponse <ForgotPasswordResultApiModel> > SendForgotPasswordLinkAsync([FromBody] ForgotPasswordCredentialsApiModel credentials) { var response = new ApiResponse <ForgotPasswordResultApiModel> { ErrorMessage = UserMessages.EmailNotRegistered }; var user = await mUserManager.Users.Include(x => x.Employee).FirstOrDefaultAsync(x => x.Email == credentials.Email); if (user == null) { response.ErrorMessage = UserMessages.EmailNotRegistered; return(response); } var code = await mUserManager.GeneratePasswordResetTokenAsync(user); var confirmationUrl = $"{Framework.Construction.Configuration["Client:Host"]}/reset-password/{HttpUtility.UrlEncode(user.Id)}/{HttpUtility.UrlEncode(code)}"; var b = await LoremIpsumEmailSender.SendUserForgotPasswordLinkAsync(user.Employee.FirstName, user.Email, confirmationUrl); if (b.Successful) { return(new ApiResponse <ForgotPasswordResultApiModel> { Response = new ForgotPasswordResultApiModel { Message = UserMessages.PasswordResetMessageSent, CallBackUrl = confirmationUrl } }); } else { return(new ApiResponse <ForgotPasswordResultApiModel> { ErrorMessage = b.Errors.ToString(), }); } }