-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/modern-agile-team/8term-…
…coko-Front into feature/#79/Section_Part
- Loading branch information
Showing
31 changed files
with
1,202 additions
and
87 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import api from './instance'; | ||
import { getCookie } from '@utils/cookies'; | ||
|
||
// 요청 인터셉터 | ||
api.interceptors.request.use(config => { | ||
// 쿠키에서 accessToken 가져오기 | ||
const accessToken: string | undefined = getCookie('accessToken'); | ||
if (accessToken) { | ||
config.headers.Authorization = `Bearer ${accessToken}`; | ||
} | ||
|
||
return config; | ||
}); | ||
|
||
// 응답 인터셉터 | ||
api.interceptors.response.use( | ||
response => { | ||
// HTTP 상태 코드가 200번대인 경우 | ||
console.log(response); | ||
return response; | ||
}, | ||
error => { | ||
// HTTP 상태 코드가 에러인 경우 | ||
return Promise.reject(error); | ||
} | ||
); |
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,23 @@ | ||
// import { setCookie } from '@utils/cookies'; | ||
|
||
const BASE_URL = import.meta.env.VITE_BASE_URL; | ||
|
||
const handleLogin = (provider: 'google' | 'kakao' | 'github') => { | ||
const redirectUrl = `${BASE_URL}/auth/${provider}`; | ||
window.location.href = redirectUrl; | ||
|
||
// 테스트용 accessToken 및 refreshToken 생성 및 쿠키에 저장 (실제 Service에 배포할 때는 주석 달거나 삭제) | ||
// const fakeAccessToken = 'test.access.token'; | ||
// const fakeRefreshToken = 'test.refresh.token'; | ||
|
||
// setCookie('accessToken', fakeAccessToken, { path: '/', maxAge: 3600 }); // 1시간 유효 | ||
// setCookie('refreshToken', fakeRefreshToken, { | ||
// path: '/', | ||
// maxAge: 3600 * 24 * 30, | ||
// }); // 30일 유효 | ||
|
||
// alert('AccessToken 생성 완료: ' + fakeAccessToken); | ||
// alert('RefreshToken 생성 완료: ' + fakeRefreshToken); | ||
}; | ||
|
||
export default handleLogin; |
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,9 @@ | ||
import { removeCookie } from '@utils/cookies'; | ||
|
||
const handleLogout = () => { | ||
removeCookie('accessToken'); | ||
removeCookie('refreshToken'); | ||
window.location.href = '/'; | ||
}; | ||
|
||
export default handleLogout; |
This file was deleted.
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
Oops, something went wrong.