Skip to content

Commit

Permalink
[refactor] 로그인 성공 시, 반환 값 수정 #49
Browse files Browse the repository at this point in the history
[refactor] 로그인 성공 시, 반환 값 수정
  • Loading branch information
yangchef1 authored May 24, 2024
2 parents b6d011f + 4bd6021 commit 59dc8e5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.sanbosillok.sanbosillokserver.api.auth.dto;

import lombok.Data;
import lombok.RequiredArgsConstructor;

@Data
public class TokenResponse {
public class LoginResponse {
private String accessToken;
private String role;

public TokenResponse(String accessToken) {
public LoginResponse(String accessToken, String role) {
this.accessToken = accessToken;
this.role = role;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sanbosillok.sanbosillokserver.api.auth.dto.CustomUserDetails;
import com.sanbosillok.sanbosillokserver.api.auth.dto.TokenResponse;
import com.sanbosillok.sanbosillokserver.api.auth.dto.LoginResponse;
import jakarta.servlet.FilterChain;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
Expand Down Expand Up @@ -57,7 +57,7 @@ protected void successfulAuthentication(HttpServletRequest request, HttpServletR
String token = jwtTokenProvider.createJwt(username, role);

response.setContentType("application/json");
response.getWriter().print(objectMapper.writeValueAsString(new TokenResponse(token)));
response.getWriter().print(objectMapper.writeValueAsString(new LoginResponse(token, role)));
}

@Override
Expand Down

0 comments on commit 59dc8e5

Please sign in to comment.