[FO] 로그인 household_seq 추가, FrontAuditCommand 추가
This commit is contained in:
@@ -40,6 +40,7 @@ public class FrontDetailService implements UserDetailsService {
|
||||
.orElseThrow(() -> new UsernameNotFoundException("Invalid username or password."));
|
||||
|
||||
return new FrontHouseholdUser(
|
||||
getHousehold.getSeq(),
|
||||
getHousehold.getHouseholdNum(),
|
||||
getHousehold.getPassword(),
|
||||
true,
|
||||
|
||||
@@ -8,9 +8,11 @@ import org.springframework.security.core.userdetails.User;
|
||||
@Getter
|
||||
public class FrontHouseholdUser extends User {
|
||||
|
||||
private Long householdSeq;
|
||||
private String ownerName;
|
||||
|
||||
public FrontHouseholdUser(
|
||||
Long householdSeq,
|
||||
String householdNum,
|
||||
String password,
|
||||
boolean enabled,
|
||||
@@ -27,6 +29,7 @@ public class FrontHouseholdUser extends User {
|
||||
credentialsNonExpired,
|
||||
accountNonLocked,
|
||||
authorities);
|
||||
this.householdSeq = householdSeq;
|
||||
this.ownerName = ownerName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.front.config.application.util;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
|
||||
public class AuditUtil {
|
||||
private AuditUtil() {}
|
||||
|
||||
public static <T extends FrontAuditCommand> T create(T cmd) {
|
||||
cmd.create();
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public static <T extends FrontAuditCommand> T update(T cmd) {
|
||||
cmd.update();
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public static <T extends FrontAuditCommand> T delete(T cmd) {
|
||||
cmd.delete();
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package app.module.front.config.application.util;
|
||||
|
||||
import app.module.core.config.adapters.web.security.domain.SocialUser;
|
||||
import app.module.front.config.application.security.FrontHouseholdUser;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AuthUtil {
|
||||
public static Long getUserSeq() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Object principal = authentication.getPrincipal();
|
||||
Long userseq = null;
|
||||
|
||||
if (principal instanceof UserDetails) {
|
||||
userseq = ((FrontHouseholdUser) principal).getHouseholdSeq();
|
||||
}
|
||||
|
||||
return userseq;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user