From 85dbefead8a7ebd0d86bf44a7e032aec0666841a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A0=95=EA=B8=B0=EC=98=81?= Date: Tue, 30 Jul 2024 15:50:01 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=8B=9C?= =?UTF-8?q?=20userType=EC=9D=84=20=EB=B0=9B=EB=8A=94=20=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/hooks/api/useAuth.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/frontend/src/hooks/api/useAuth.js b/frontend/src/hooks/api/useAuth.js index 1d759f4..d7a928f 100644 --- a/frontend/src/hooks/api/useAuth.js +++ b/frontend/src/hooks/api/useAuth.js @@ -15,11 +15,15 @@ export function useAuth() { return instance .post(`${API_URL}/user/login`, formData) .then(({ data, config }) => { - const { 'access-token': accessToken } = data; + const { role: role, 'access-token': accessToken } = data; config.headers.Authorization = `${accessToken}`; setToken(accessToken); - // TODO: userType 구분 추가 - setUserType('student'); + + if (role === 'ADMIN') { + setUserType('teacher'); + } else if (role === 'STUDENT') { + setUserType('student'); + } }) .catch((e) => { alert('아이디 또는 비밀번호를 다시 확인해주세요.');