Skip to content

Commit 91dcb00

Browse files
committed
fix: 사용자 인증 정보 저장 로직 추가
1 parent 5149d6a commit 91dcb00

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/pages/Register/Register.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ChangeEvent, useState } from 'react';
22
import { useLocation } from 'react-router-dom';
33
import { TermKey } from '@ts/Term';
44
import useRouter from '@router/useRouter';
5+
import useAuthInfo from '@hooks/useAuthInfo';
56
import Button from '@components/Common/Button';
67
import MyPageInput, { MyPageInputProps } from '@components/MyPage/MyPageInput/MyPageInput';
78
import ProfileCircle from '@components/MyPage/ProfileCircle/ProfileCircle';
@@ -51,6 +52,7 @@ const termInputs: TermInputItem[] = [
5152
const Register = () => {
5253
const { navToRegisterDone, navToTerm } = useRouter();
5354
const location = useLocation();
55+
const { setAuthInfo } = useAuthInfo();
5456

5557
// WebView 환경 감지
5658
const isWebView = !!(window as any).ReactNativeWebView;
@@ -258,6 +260,16 @@ const Register = () => {
258260

259261
if (!res) return;
260262

263+
// 토큰 및 사용자 정보 저장 (브라우저/WebView 모두)
264+
if (res.access_token && res.refresh_token) {
265+
setAuthInfo(res.access_token, res.refresh_token, {
266+
email: values.email,
267+
nickname: values.name,
268+
profileImage: profileImage || undefined,
269+
provider: provider.toUpperCase(),
270+
});
271+
}
272+
261273
// sessionStorage 정리
262274
sessionStorage.removeItem('register_email');
263275
sessionStorage.removeItem('register_provider');
@@ -270,10 +282,9 @@ const Register = () => {
270282
token: res.access_token,
271283
}),
272284
);
273-
return;
274285
}
275286

276-
// 일반 브라우저: Done 페이지로 이동
287+
// Done 페이지로 이동
277288
navToRegisterDone();
278289
};
279290

0 commit comments

Comments
 (0)