Skip to content

Commit

Permalink
Merge pull request #100 from SKKUD/Feature_Refresh_CastingErrorFix
Browse files Browse the repository at this point in the history
fix: principalDetails authorities'type changed, casting error fixed
  • Loading branch information
willjsw authored Nov 24, 2023
2 parents 792b395 + a26a311 commit 1e81a2b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RefreshTokenController {

@GetMapping("/refresh")
public ResponseEntity<Void> refresh(HttpServletRequest request, @AuthenticationPrincipal PrincipalDetails userDetails) {
String newAccessToken = refreshTokenService.refreshAccessToken(request,userDetails.getUserId(),userDetails.getUsername(), (Role) userDetails.getAuthorities().toArray()[0]);
String newAccessToken = refreshTokenService.refreshAccessToken(request,userDetails.getUserId(),userDetails.getUsername(), Role.valueOf(userDetails.getAuthorities().get(0).getAuthority()));
return ResponseEntity.noContent()
.header(HttpHeaders.AUTHORIZATION, "Bearer " + newAccessToken)
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.skklub.admin.security.auth;

import com.skklub.admin.domain.User;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.ArrayList;
import java.util.Collection;

public class PrincipalDetails implements UserDetails {

Expand All @@ -17,8 +17,8 @@ public PrincipalDetails(User user){

//해당 유저 권한 리턴
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
Collection<GrantedAuthority> collect = new ArrayList<>();
public ArrayList<? extends GrantedAuthority> getAuthorities() {
ArrayList<GrantedAuthority> collect = new ArrayList<>();
collect.add((GrantedAuthority) () -> String.valueOf(user.getRole()));
return collect;
}
Expand Down

0 comments on commit 1e81a2b

Please sign in to comment.