-
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.
- Loading branch information
Showing
3 changed files
with
45 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import axios from 'axios'; | ||
|
||
export default function Bridge(){ | ||
window.alert("브릿지도착"); | ||
axios({ | ||
method: "GET", | ||
url: `http://localhost:8080/api/bridge`, | ||
headers: { | ||
'token': localStorage.getItem("token") | ||
} | ||
}) | ||
.then((res) => { | ||
console.log("로그인 성공") | ||
//history.replace("/main") // 토큰 받았았고 로그인됐으니 화면 전환시켜줌(메인으로) | ||
|
||
document.location.href = "/main" | ||
|
||
}).catch((err) => { | ||
window.alert("토큰이 유효하지않음", err); | ||
window.alert("로그인에 실패하였습니다."); | ||
|
||
document.location.href = "/" // 로그인 실패하면 로그인화면으로 돌려보냄 | ||
}) | ||
return(<></>); | ||
} |
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,30 +1,42 @@ | ||
import axios from 'axios'; | ||
|
||
export default function KakaoOauth(){ | ||
console.log("adfasdfasfdsadsfad") | ||
let code = new URL(window.location.href).searchParams.get('code'); | ||
console.log(code); | ||
console.log(code); | ||
console.log(code); | ||
console.log(code); | ||
console.log(code); | ||
console.log(code); | ||
console.log(code); | ||
console.log(code); | ||
console.log(code); | ||
|
||
axios({ | ||
method: "GET", | ||
url: `http://localhost:8080/oauth/kakao?code=${code}` | ||
url: `http://localhost:8080/api/oauth/kakao?code=${code}` | ||
}) | ||
.then((res) => { | ||
console.log(res); // 토큰이 넘어올 것임 | ||
|
||
console.log(res); | ||
console.log(res.data); | ||
const tokenData = res.data; | ||
const accessToken = res.data.data.accessToken; | ||
|
||
localStorage.setItem("token", accessToken); //예시로 로컬에 저장함 | ||
|
||
localStorage.setItem("token", JSON.stringify({tokenData})); //예시로 로컬에 저장함 | ||
console.log("로그인 성공") | ||
//history.replace("/main") // 토큰 받았았고 로그인됐으니 화면 전환시켜줌(메인으로) | ||
document.location.href = "/main" | ||
|
||
}).catch((err) => { | ||
console.log("소셜로그인 에러", err); | ||
window.location.href = "/bridge" | ||
}).catch((err) => { | ||
console.log("소셜로그인 에러", err); | ||
window.alert("로그인에 실패하였습니다."); | ||
|
||
document.location.href = "/test" // 로그인 실패하면 로그인화면으로 돌려보냄 | ||
}) | ||
|
||
console.log("adfdaf") | ||
return(<></>); | ||
} |