Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/feature/#18-1' into…
Browse files Browse the repository at this point in the history
… feature/#29
  • Loading branch information
runasy-koonta committed May 26, 2024
2 parents da47fde + 52b90fa commit f9c13de
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/main/java/meltingpot/server/config/TokenProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,7 @@ public Authentication getAuthentication(String accessToken) {
// UserDetails 객체를 만들어서 Authentication 리턴
UserDetails principal = new User(claims.getSubject(), "", authorities);

// 유저 객체를 등록
Optional<Account> account = accountRepository.findByUsername(principal.getUsername());

return new UsernamePasswordAuthenticationToken(account, accessToken, authorities);
return new UsernamePasswordAuthenticationToken(principal, accessToken, authorities);
}


Expand Down
17 changes: 17 additions & 0 deletions src/main/java/meltingpot/server/util/CurrentUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package meltingpot.server.util;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.security.core.annotation.AuthenticationPrincipal;

@Target({ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@AuthenticationPrincipal(expression = "@authService.getUserInfo()")
//인증된 사용자의 Principal 정보를 참조할 수 있다.
public @interface CurrentUser {

}

0 comments on commit f9c13de

Please sign in to comment.