change password
This commit is contained in:
parent
718ad3391e
commit
a32d5a499f
@ -2,12 +2,12 @@ package com.iconplus.smartproc.controller;
|
||||
|
||||
import com.iconplus.smartproc.helper.model.EmptyRequest;
|
||||
import com.iconplus.smartproc.helper.model.EmptyResponse;
|
||||
import com.iconplus.smartproc.model.request.ForgotPasswordRequest;
|
||||
import com.iconplus.smartproc.model.request.ChangePasswordRequest;
|
||||
import com.iconplus.smartproc.model.request.LoginRequest;
|
||||
import com.iconplus.smartproc.model.request.RefreshTokenRequest;
|
||||
import com.iconplus.smartproc.model.response.LoginResponse;
|
||||
import com.iconplus.smartproc.model.response.RefreshTokenResponse;
|
||||
import com.iconplus.smartproc.service.authentication.ForgotPasswordService;
|
||||
import com.iconplus.smartproc.service.authentication.ChangePasswordService;
|
||||
import com.iconplus.smartproc.service.authentication.LoginService;
|
||||
import com.iconplus.smartproc.service.authentication.LogoutService;
|
||||
import com.iconplus.smartproc.service.authentication.TokenManagementService;
|
||||
@ -21,16 +21,16 @@ public class AuthenticationController {
|
||||
private LoginService loginService;
|
||||
private TokenManagementService tokenManagementService;
|
||||
private LogoutService logoutService;
|
||||
private ForgotPasswordService forgotPasswordService;
|
||||
private ChangePasswordService changePasswordService;
|
||||
|
||||
public AuthenticationController(LoginService loginService,
|
||||
TokenManagementService tokenManagementService,
|
||||
LogoutService logoutService,
|
||||
ForgotPasswordService forgotPasswordService) {
|
||||
ChangePasswordService changePasswordService) {
|
||||
this.loginService = loginService;
|
||||
this.tokenManagementService = tokenManagementService;
|
||||
this.logoutService = logoutService;
|
||||
this.forgotPasswordService = forgotPasswordService;
|
||||
this.changePasswordService = changePasswordService;
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
@ -49,9 +49,9 @@ public class AuthenticationController {
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/forgot-password")
|
||||
public EmptyResponse forgotPassword(@RequestBody ForgotPasswordRequest forgotPasswordRequest) {
|
||||
return forgotPasswordService.execute(forgotPasswordRequest);
|
||||
@PostMapping("/change-password")
|
||||
public EmptyResponse changePassword(@RequestBody ChangePasswordRequest changePasswordRequest) {
|
||||
return changePasswordService.execute(changePasswordRequest);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import lombok.NoArgsConstructor;
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ForgotPasswordRequest extends BaseRequest {
|
||||
public class ChangePasswordRequest extends BaseRequest {
|
||||
private String currentPassword;
|
||||
private String newPassword;
|
||||
private String confirmationPassword;
|
@ -4,7 +4,7 @@ import com.iconplus.smartproc.exception.BusinessException;
|
||||
import com.iconplus.smartproc.helper.context.ApiContext;
|
||||
import com.iconplus.smartproc.helper.model.EmptyResponse;
|
||||
import com.iconplus.smartproc.helper.service.BaseService;
|
||||
import com.iconplus.smartproc.model.request.ForgotPasswordRequest;
|
||||
import com.iconplus.smartproc.model.request.ChangePasswordRequest;
|
||||
import com.iconplus.smartproc.repository.UsersRepository;
|
||||
import com.iconplus.smartproc.service.CommonService;
|
||||
import com.iconplus.smartproc.util.Constants;
|
||||
@ -14,12 +14,12 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ForgotPasswordService implements BaseService<ForgotPasswordRequest, EmptyResponse> {
|
||||
public class ChangePasswordService implements BaseService<ChangePasswordRequest, EmptyResponse> {
|
||||
|
||||
private ApiContext apiContext;
|
||||
private UsersRepository usersRepository;
|
||||
private CommonService commonService;
|
||||
public ForgotPasswordService(UsersRepository usersRepository,
|
||||
public ChangePasswordService(UsersRepository usersRepository,
|
||||
ApiContext apiContext,
|
||||
CommonService commonService) {
|
||||
this.usersRepository = usersRepository;
|
||||
@ -28,7 +28,7 @@ public class ForgotPasswordService implements BaseService<ForgotPasswordRequest,
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmptyResponse execute(ForgotPasswordRequest input) {
|
||||
public EmptyResponse execute(ChangePasswordRequest input) {
|
||||
|
||||
Long id = Long.valueOf(apiContext.getUserId());
|
||||
var users = usersRepository.findByIdAndIsDeleteFalse(id)
|
||||
@ -48,7 +48,7 @@ public class ForgotPasswordService implements BaseService<ForgotPasswordRequest,
|
||||
}
|
||||
|
||||
String newPassword = commonService.getPassword(input.getNewPassword());
|
||||
String confirmationPassword = commonService.getPassword(input.getNewPassword());
|
||||
String confirmationPassword = commonService.getPassword(input.getConfirmationPassword());
|
||||
|
||||
|
||||
if (!StringUtils.equalsIgnoreCase(newPassword, confirmationPassword)) {
|
Loading…
x
Reference in New Issue
Block a user