Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ function App() {
<Router>
<Routes>
<Route path="/" element={<Login />} />
<Route path="/login/:code" element={<Login />} />
<Route path="/auth/callback" element={<AuthCallback />} />

<Route path="/auth/callback/:code" element={<AuthCallback />} />
<Route element={<AppLayout />}>
<Route path="/home" element={<Home />} />
<Route path="/invited" element={<Invited />} />
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/pages/AuthCallback.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@ const AuthCallback = () => {
if (token) {
localStorage.setItem("access_token", token);

const code = sessionStorage.getItem("invite-code");
sessionStorage.removeItem("invite-code");

//navigate("/home", { replace: true });
// OAuth 콜백에서는 window.location 사용
window.location.replace("/home");
if (code === null) {
window.location.replace("/home");
}
else {
window.location.replace(`/invite/${code}`);
}

} else {
sessionStorage.removeItem("invite-code");
navigate("/");
}
}, []);
Expand Down
14 changes: 12 additions & 2 deletions frontend/src/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { useEffect } from "react";
import './Login.css';
import logo from "../assets/logo.png";
import googleLogo from "../assets/googleLogo.png";
import { useNavigate } from "react-router-dom";
import { useNavigate, useParams } from "react-router-dom";
import { API_BASE_URL } from "../config/api";

const Login = () => {
const navigate = useNavigate();

const { code } = useParams();

// 이제 AuthCallback.jsx에서 처리하므로 주석 처리
// const navigateToHome = () => {
// navigate("/home");
Expand All @@ -27,7 +29,15 @@ const Login = () => {
const response = await fetch(`${API_BASE_URL}/user/google/login`);
const data = await response.json();

window.location.href = data.auth_url;
if (!code) {
sessionStorage.removeItem("invite-code");
window.location.href = data.auth_url;
}
else {
sessionStorage.setItem("invite-code", code);
window.location.href = data.auth_url;
}

} catch (error) {
console.error("구글 로그인 실패", error);
}
Expand Down
Loading