fix decrypt password

This commit is contained in:
dirgantarasiahaan
2023-05-28 17:36:28 +07:00
parent cab86cf8fa
commit c93f666056
77 changed files with 405 additions and 129 deletions
@@ -14,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -54,7 +55,11 @@ public class LoginService implements BaseService<LoginRequest, LoginResponse> {
Constants.ERR_TTL_10003,
String.format(Constants.ERR_MSG_10003, input.getEmail())));
if (!StringUtils.equalsIgnoreCase(input.getPassword(), userRoleView.getPassword())) {
String password = commonService.getPassword(input.getPassword());
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
boolean isValidPassword = bCryptPasswordEncoder.matches(password, userRoleView.getPassword());
if (!isValidPassword) {
throw new BusinessException(HttpStatus.CONFLICT,
Constants.ERR_CODE_10004,
Constants.ERR_TTL_10004,
@@ -84,7 +89,9 @@ public class LoginService implements BaseService<LoginRequest, LoginResponse> {
if (StringUtils.isBlank(accessToken) || StringUtils.isBlank(refreshToken)) {
log.error("token null");
throw new BusinessException("err", "err", "err");
throw new BusinessException(Constants.ERR_CODE_10008,
Constants.ERR_TTL_10008,
Constants.ERR_MSG_10008);
}
commonService.saveUserToken(TokenManagement.builder()
@@ -93,7 +100,6 @@ public class LoginService implements BaseService<LoginRequest, LoginResponse> {
.refreshToken(refreshToken)
.build(), accessTokenExp);
return LoginResponse.builder()
.accessToken(accessToken)
.validity(accessTokenExp * 60)