public bool SetPassword(SetPasswordDtoCommand command) { string email = command.Email.ToLower(); string password = command.Password; string otp = command.OTP; string salt = Generator.GenerateRandomString(10); string hashPass = Generator.HashPassword(password, salt); return(_storeRepository.AddPassword(email, hashPass, salt, otp)); }
public IActionResult CallApiSetPass(string otp, string email, string password) { email = email.ToLower(); bool isEmail = _authService.ChechEmail(email); if (!isEmail) { return(RedirectToAction("Error(", "Register", new { message = "E-Mail นี้ไม่มีในระบบ" })); } SetPasswordDtoCommand command = new SetPasswordDtoCommand() { OTP = otp, Email = email, Password = password }; bool isSetPass = _authService.SetPassword(command); if (!isSetPass) { return(RedirectToAction("Error(", "Register", new { message = "ไม่สามารถตั้งรหัสได้โปรดกด Forgot password?\nเพื่อรับ Link ตั้งรหัสผ่านใหม่ใน Email" })); } return(RedirectToAction("SuccessPage", "Register", new { message = "ตั้งรหัสสำเร็จเรียบร้อย" })); }