|
@@ -266,7 +266,7 @@ namespace MTWorkHR.Application.Services
|
|
|
|
|
|
return input;
|
|
|
}
|
|
|
- public async Task<bool> ConfirmEmail(ForgetPasswordDto input)
|
|
|
+ public async Task<bool> ConfirmEmail(ConfirmEmailDto input)
|
|
|
{
|
|
|
var user = await _userManager.FindByIdAsync(input.UserId);
|
|
|
if (user == null)
|
|
@@ -352,12 +352,9 @@ namespace MTWorkHR.Application.Services
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Task<UserDto> UpdateWithoutChildren(UserDto input)
|
|
|
- {
|
|
|
- throw new NotImplementedException();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
- public async Task<bool> IsExpiredToken(ForgetPasswordDto input)
|
|
|
+ public async Task<bool> IsExpiredToken(ConfirmEmailDto input)
|
|
|
{
|
|
|
var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
|
|
|
if (user == null)
|
|
@@ -366,7 +363,7 @@ namespace MTWorkHR.Application.Services
|
|
|
var result = await _userManager.VerifyUserTokenAsync(user, "Default", purpose, input.Token);
|
|
|
return !result;
|
|
|
}
|
|
|
- public async Task<bool> ForgetPassword1(ForgetPasswordDto model)
|
|
|
+ public async Task<bool> ForgetPasswordxxxxxxxxxxxxxx(ConfirmEmailDto model)
|
|
|
{
|
|
|
var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == model.UserId);
|
|
|
if (user == null)
|
|
@@ -394,7 +391,7 @@ namespace MTWorkHR.Application.Services
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
- public async Task ForgetPasswordMail1(string email)
|
|
|
+ public async Task ForgetPasswordMailxxxxxxxxxxxx(string email)
|
|
|
{
|
|
|
|
|
|
var foundUser = await _userManager.FindByEmailAsync(email);
|
|
@@ -424,30 +421,33 @@ namespace MTWorkHR.Application.Services
|
|
|
}
|
|
|
|
|
|
|
|
|
- public async Task<string> ForgetPasswordMail(string email) //Begin forget password
|
|
|
+ public async Task<ForgetPasswordResponseDto> ForgetPasswordMail(string email) //Begin forget password
|
|
|
{
|
|
|
var foundUser = await _userManager.FindByEmailAsync(email);
|
|
|
if (foundUser != null)
|
|
|
{
|
|
|
string oneTimePassword = await _oTPService.RandomOneTimePassword(foundUser.Id);
|
|
|
- await _oTPService.SentOTPByMail(foundUser.Id,foundUser.Email, oneTimePassword);
|
|
|
- return foundUser.Id;
|
|
|
+ await _oTPService.SentOTPByMail(foundUser.Id, foundUser.Email, oneTimePassword);
|
|
|
+ ForgetPasswordResponseDto res = new ForgetPasswordResponseDto { UserId = foundUser.Id};
|
|
|
+ return res;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ public async Task<bool> VerifyOTP(VerifyOTPDto input)
|
|
|
+ {
|
|
|
+ if (! await _oTPService.VerifyOTP(input.UserId, input.OTP))
|
|
|
+ throw new AppException(ExceptionEnum.WrongOTP);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
public async Task<bool> ForgetPassword(ForgetPasswordDto input)
|
|
|
{
|
|
|
var user = await _userManager.Users.IgnoreQueryFilters().FirstOrDefaultAsync(x => x.Id == input.UserId);
|
|
|
if (user == null)
|
|
|
throw new AppException(ExceptionEnum.RecordNotExist);
|
|
|
-
|
|
|
- if (!_oTPService.VerifyOTP(user.Id, input.OTP).Result)
|
|
|
- throw new AppException(ExceptionEnum.WrongOTP);
|
|
|
+
|
|
|
string resetToken = await _userManager.GeneratePasswordResetTokenAsync(user);
|
|
|
|
|
|
var result = await _userManager.ResetPasswordAsync(user, resetToken, input.Password);
|