관리자 로그인 이력 수정
This commit is contained in:
@@ -65,17 +65,18 @@ public class AdminAuthSuccessEvent {
|
||||
"security.password.change.notify", adminUser.getRemainPasswordDays()));
|
||||
}
|
||||
|
||||
// 로그인 활성화 기록 생성
|
||||
// loggedInUserSavePortIn.connect(
|
||||
// LoggedInUserSaveCmd.builder()
|
||||
// .loggedInUserId(
|
||||
// LoggedInUserIdSaveCmd.builder()
|
||||
// .appType(AppType.ADMIN)
|
||||
// .id(authentication.getName())
|
||||
// .build())
|
||||
// .clientIP(CommonUtil.getClientIP(request))
|
||||
// .lastLoggedInAt(LocalDateTime.now())
|
||||
// .build());
|
||||
// 로그인 이력 쌓기
|
||||
loggedInUserSavePortIn.connect(
|
||||
LoggedInUserSaveCmd.builder()
|
||||
.loggedInUserId(
|
||||
LoggedInUserIdSaveCmd.builder()
|
||||
.appType(AppType.ADMIN)
|
||||
.id(authentication.getName())
|
||||
.build())
|
||||
.clientIP(CommonUtil.getClientIP(request))
|
||||
.lastLoggedInAt(LocalDateTime.now())
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
@EventListener
|
||||
|
||||
@@ -46,6 +46,7 @@ public class AdminDetailsService implements UserDetailsService {
|
||||
adminUser.getPassword(),
|
||||
adminUser.getRoles().stream().map(CoreRole::getId).findFirst().orElse(null),
|
||||
adminUser.getRegionMainCode(),
|
||||
adminUser.getLastLoginIp(),
|
||||
!accountDisabled,
|
||||
true,
|
||||
isCredentialsNonExpired(adminUser.getPasswordUpdatedAt()),
|
||||
|
||||
@@ -10,6 +10,7 @@ public class AdminUser extends User {
|
||||
private Long seq;
|
||||
private String roleId;
|
||||
private String regionMainCode;
|
||||
private String lastLoginIp;
|
||||
private long remainPasswordDays;
|
||||
|
||||
public AdminUser(
|
||||
@@ -18,6 +19,7 @@ public class AdminUser extends User {
|
||||
String password,
|
||||
String roleId,
|
||||
String regionMainCode,
|
||||
String lastLoginIp,
|
||||
boolean enabled,
|
||||
boolean accountNonExpired,
|
||||
boolean credentialsNonExpired,
|
||||
@@ -35,6 +37,7 @@ public class AdminUser extends User {
|
||||
this.seq = seq;
|
||||
this.roleId = roleId;
|
||||
this.regionMainCode = regionMainCode;
|
||||
this.lastLoginIp = lastLoginIp;
|
||||
this.remainPasswordDays = remainPasswordDays;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,14 @@ public class AdminUtil {
|
||||
AdminUser user = (AdminUser) authentication.getPrincipal();
|
||||
return user.getRegionMainCode().isEmpty() ? null : user.getRegionMainCode();
|
||||
}
|
||||
|
||||
public static String getLoginUserLastIp() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null || !(authentication.getPrincipal() instanceof AdminUser)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
AdminUser user = (AdminUser) authentication.getPrincipal();
|
||||
return user.getLastLoginIp();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user