// this defines a public method named ForgotPassword that returns // an instance of ForgotPasswordResult and takes one parameter of type // ForgotPasswordRequest. public bool ForgotPassword(AppUserForgotPasswordRequest req) { ForgotPasswordResult forgotPassword = new ForgotPasswordResult(); string ResetToken = null; string FirstName = null; dataProvider.ExecuteNonQuery( "AppUser_Validate", (parameters) => { parameters.AddWithValue("@Email", req.Email); parameters.Add("@FirstName", SqlDbType.NVarChar, 20).Direction = ParameterDirection.Output; parameters.Add("@ResetToken", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output; }, // the stuff above goes to the database, after the database code is finsihed, gets the data or nulls. (parameters) => //setting empty box to be filled when we get the data back from database. { FirstName = parameters["@FirstName"].Value as string; ResetToken = parameters["@ResetToken"].Value as string; }); if (ResetToken != null) { EmailSenderService.SendForgotPasswordEmail(FirstName, ResetToken, req.Email).Wait(); return(true); } else { return(false); } }
public bool ResetNewPassword(AppUserResetNewPasswordRequest req) { AppUserResetPasswordResult resetPassResult = new AppUserResetPasswordResult(); string Password = BCrypt.HashPassword(req.PasswordHash); string FirstName = null; string Email = null; dataProvider.ExecuteNonQuery( "AppUser_ResetPassword", (parameters) => { parameters.AddWithValue("@PasswordHash", Password); parameters.AddWithValue("@ResetToken", req.ResetToken); parameters.Add("@FirstName", SqlDbType.NVarChar, 20).Direction = ParameterDirection.Output; parameters.Add("@Email", SqlDbType.NVarChar, 50).Direction = ParameterDirection.Output; }, (parameters) => { FirstName = parameters["@FirstName"].Value as string; Email = parameters["@Email"].Value as string; }); if (Email != null) { EmailSenderService.SendNewPasswordEmailConfirmation(FirstName, Email).Wait(); return(true); } else { return(false); } }