@@ -47,7 +47,7 @@ public ResponseAccount.Token authenticate(String username, String password) {
47
47
48
48
// 인증 정보를 기준으로 jwt access 토큰 생성
49
49
String accessToken = tokenProvider .createToken (authentication );
50
- Date expiredTime = tokenProvider .getExpiredTime (accessToken );
50
+ Date expiredTime = tokenProvider .getExpiredTime (accessToken ); // 토큰 정보에서 만료된 정보를 가져옴
51
51
52
52
// 위에서 loadUserByUsername를 호출하였으므로 AccountAdapter가 시큐리티 컨텍스트에 저장되어 Account 엔티티 정보를 우리는 알 수 있음
53
53
// 유저 정보에서 중치를 꺼내 리프레시 토큰 가중치에 할당, 나중에 액세스토큰 재발급 시도 시 유저정보 가중치 > 리프레시 토큰이라면 실패
@@ -87,6 +87,30 @@ public ResponseAccount.Information registerMember(RequestAccount.RegisterMember
87
87
return ResponseAccount .Information .of (accountRepository .save (user ));
88
88
}
89
89
90
+ @ Override
91
+ public ResponseAccount .Information registerAdmin (RequestAccount .RegisterAdmin registerAdminDto ) {
92
+ Optional <Account > accountOptional = accountRepository .findOneWithAuthoritiesByUsername (registerAdminDto .username ());
93
+
94
+ if (accountOptional .isPresent ()) {
95
+ throw new ApplicationException (CommonErrorCode .CONFLICT , "이미 가입되어있는 유저" );
96
+ }
97
+
98
+ //이건 부팅 시 data.sql에서 INSERT로 디비에 반영
99
+ Authority authority = Authority .builder ()
100
+ .authorityName ("ROLE_ADMIN" )
101
+ .build ();
102
+
103
+ Account user = Account .builder ()
104
+ .username (registerAdminDto .username ())
105
+ .password (passwordEncoder .encode (registerAdminDto .password ()))
106
+ .nickname (registerAdminDto .nickname ())
107
+ .authorities (Collections .singleton (authority ))
108
+ .activated (true )
109
+ .build ();
110
+
111
+ return ResponseAccount .Information .of (accountRepository .save (user ));
112
+ }
113
+
90
114
@ Transactional (readOnly = true )
91
115
@ Override
92
116
public ResponseAccount .Information getAccountWithAuthorities (String username ) {
0 commit comments