2023-08-24 13:19:10 +00:00
|
|
|
const authCode = new URL(document.location).searchParams.get('code')
|
|
|
|
|
|
|
|
if(typeof authCode !== undefined) {
|
|
|
|
fetch('https://crss-api.theclashfruit.workers.dev/login', {
|
|
|
|
method: 'POST',
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json'
|
|
|
|
},
|
2023-08-24 14:23:09 +00:00
|
|
|
body: JSON.stringify({ authCode: authCode })
|
2023-08-24 13:19:10 +00:00
|
|
|
})
|
2023-08-24 14:23:09 +00:00
|
|
|
.then(res => res.json())
|
2023-08-24 13:19:10 +00:00
|
|
|
.then(res => {
|
2023-08-24 14:38:04 +00:00
|
|
|
localStorage.setItem('token', res.access_token)
|
|
|
|
localStorage.setItem('refresh', res.refresh_token)
|
2023-08-24 13:19:10 +00:00
|
|
|
})
|
|
|
|
}
|