-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
b9e5692
commit 1792a8f
Showing
20 changed files
with
969 additions
and
83 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
} | ||
|
||
.subjectName { | ||
all:unset; | ||
font-family: "SF Pro Display"; | ||
font-style: normal; | ||
font-weight: 600; | ||
|
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 |
---|---|---|
@@ -1,16 +1,64 @@ | ||
import { useLocation } from 'react-router-dom'; | ||
import { useEffect } from 'react'; | ||
import { ClassNames } from '@emotion/react'; | ||
import styles from './Login.module.css'; | ||
import { useLocation } from "react-router-dom"; | ||
import { useEffect } from "react"; | ||
import { ClassNames } from "@emotion/react"; | ||
import styles from "./Login.module.css"; | ||
import { ReactComponent as Wekey42 } from "../42wekey.svg"; | ||
import { useRecoilState } from "recoil"; | ||
import { profileState } from "../../utils/recoil/user"; | ||
import { redirect } from "react-router-dom"; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export default function Login(){ | ||
const loginUrl = 'https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-51653061ff64d007d7e3269016e85b84b88ea3acd89dabcb3370e475ea6810b8&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2Flogin%2Foauth2%2Fcode%2Fseoul42&response_type=code'; | ||
export default function Login() { | ||
const navigate = useNavigate(); | ||
const baseUrl = `${process.env.REACT_APP_END_POINT}`; | ||
const loginUrl = `${baseUrl}/oauth2/authorization`; | ||
const [userInfo, setUserInfo] = useRecoilState(profileState); | ||
useEffect(()=> { | ||
if (localStorage.getItem("42ence-token")) { | ||
setUserInfo({ isLogin: true }); | ||
navigate('/main'); | ||
} | ||
},[]) | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<Wekey42 className={styles.logo}/> | ||
<a href={loginUrl} className={styles.loginBtn}>로그인</a> | ||
</div> | ||
); | ||
}; | ||
return ( | ||
<div className={styles.container}> | ||
|
||
<Wekey42 className={styles.logo} /> | ||
<a href={loginUrl} className={styles.loginBtn}> | ||
로그인 | ||
|
||
</a> | ||
</div> | ||
); | ||
} | ||
|
||
// const url = new URL(window.location.href); | ||
// const href = url.href; | ||
// const accessToken = href.split("token=")[1]; | ||
// useEffect(() => { | ||
// if (accessToken) { | ||
// localStorage.setItem("42ence-token", accessToken); | ||
// setUserInfo({isLogin:true}); | ||
// console.log(userInfo.isLogin) | ||
// redirect(`${baseUrl}`); | ||
// } | ||
// if (localStorage.getItem("42ence-token")) { | ||
// setUserInfo({isLogin:true}); | ||
// console.log(userInfo.isLogin) | ||
// redirect(`${baseUrl}`); | ||
// } | ||
// setUserInfo({isLogin:false}); | ||
// if (isLogged) { | ||
// fetch(`${baseUrl}/user/me`, { | ||
// headers: { | ||
// Authorization: `Bearer ${localStorage.getItem("42ence-token")}`, | ||
// }, | ||
// }) | ||
// .then((res) => res.json()) | ||
// .then((data) => setUserInfo(data)); | ||
// console.log(userInfo.intraId); | ||
// } | ||
// }, [userInfo.isLogin]); | ||
// useEffect(()=> { | ||
// console.log(userInfo.isLogin) | ||
// },[userInfo.isLogin]) |
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,56 @@ | ||
import { useEffect, useState } from "react"; | ||
import { redirect, useNavigate } from "react-router"; | ||
import { useRecoilState } from "recoil"; | ||
import { profileState } from "../../utils/recoil/user"; | ||
|
||
export default function LoginCheck () { | ||
const navigate = useNavigate(); | ||
const baseUrl = `${process.env.REACT_APP_END_POINT}`; | ||
const [isLogged, setIsLogged] = useState(false); | ||
const [userInfo, setUserInfo] = useRecoilState(profileState); | ||
const url = new URL(window.location.href); | ||
const href = url.href; | ||
const accessToken = href.split("token=")[1]; | ||
useEffect(() => { | ||
if (accessToken) { | ||
localStorage.setItem("42ence-token", accessToken); | ||
setUserInfo({isLogin:true}); | ||
console.log(userInfo.isLogin) | ||
navigate('/main'); | ||
// redirect(`${baseUrl}`); | ||
} | ||
else if (localStorage.getItem("42ence-token")) { | ||
setUserInfo({isLogin:true}); | ||
console.log(userInfo.isLogin) | ||
navigate('/main'); | ||
redirect(`${baseUrl}`); | ||
} | ||
else if (isLogged) { | ||
fetch(`${baseUrl}/user/me`, { | ||
headers: { | ||
Authorization: `Bearer ${localStorage.getItem("42ence-token")}`, | ||
}, | ||
}) | ||
.then((res) => res.json()) | ||
.then((data) => setUserInfo(data)); | ||
} | ||
else { | ||
setUserInfo({isLogin:false}); | ||
|
||
} | ||
navigate('/login'); | ||
redirect(`/login`); | ||
}, []); | ||
useEffect(()=> { | ||
if (localStorage.getItem("42ence-token")) | ||
{fetch(`${baseUrl}/user/me`, { | ||
headers: { | ||
Authorization: `Bearer ${localStorage.getItem("42ence-token")}`, | ||
}, | ||
}) | ||
.then((res) => res.json()) | ||
.then((data) => setUserInfo(data)); | ||
console.log(userInfo.intra_id); | ||
}},[]) | ||
return (<div></div>); | ||
} |
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
Oops, something went wrong.