Skip to content

Commit 091e773

Browse files
committed
♻️ refactor: authentication 추가
1 parent 5a3a8c2 commit 091e773

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

backend/src/main/java/io/f1/backend/domain/game/websocket/GameSocketController.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@
1313
import io.f1.backend.domain.game.dto.request.GameStartRequest;
1414
import io.f1.backend.domain.user.dto.UserPrincipal;
1515

16+
import java.security.Principal;
1617
import lombok.RequiredArgsConstructor;
1718

1819
import org.springframework.messaging.Message;
1920
import org.springframework.messaging.handler.annotation.DestinationVariable;
2021
import org.springframework.messaging.handler.annotation.MessageMapping;
2122
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
23+
import org.springframework.security.core.Authentication;
2224
import org.springframework.stereotype.Controller;
2325

2426
@Controller
@@ -117,6 +119,7 @@ private static String getSessionId(Message<?> message) {
117119

118120
private static UserPrincipal getSessionUser(Message<?> message) {
119121
StompHeaderAccessor accessor = StompHeaderAccessor.wrap(message);
120-
return (UserPrincipal) accessor.getUser();
122+
Authentication auth = (Authentication) accessor.getUser();
123+
return (UserPrincipal) auth.getPrincipal();
121124
}
122125
}

0 commit comments

Comments
 (0)