-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
83 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { useEffect } from "react"; | ||
import axios from "axios"; | ||
import { useNavigate, useLocation } from "react-router-dom"; | ||
import { useSetRecoilState } from "recoil"; | ||
import { loginState } from "../../store/atoms"; | ||
|
||
const Login = () => { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const setLoginState = useSetRecoilState(loginState); | ||
|
||
useEffect(() => { | ||
// Parse the URL to get the JWT | ||
const jwt = new URL(window.location.href).searchParams.get("jwt"); | ||
|
||
if (jwt) { | ||
// If JWT exists, set it in the headers | ||
axios.defaults.headers.common["Authorization"] = `Bearer ${jwt}`; | ||
|
||
// Set login state to true | ||
setLoginState(true); | ||
|
||
// Redirect to the home screen | ||
navigate("/"); | ||
console.log("로그인!"); | ||
} | ||
}, [navigate, location.search, setLoginState]); | ||
|
||
return ( | ||
<div> | ||
{/* You can add a loading spinner or other UI elements here */} | ||
Logging in... | ||
</div> | ||
); | ||
}; | ||
|
||
export default Login; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters