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