Оптимизировал проверки
This commit is contained in:
parent
4f02f56f85
commit
3c76c7dc09
@ -62,12 +62,22 @@ export const grabTokenData = (token: string): TokenData|null => {
|
||||
if (!isClient()) {
|
||||
return null
|
||||
}
|
||||
|
||||
const parts = token.split('.')
|
||||
let payload = 3 === parts.length && parts[1] ? JSON.parse(window.atob(parts[1])) : null
|
||||
let headers = 3 === parts.length && parts[0] ? JSON.parse(window.atob(parts[0])) : null
|
||||
if (!payload || !headers){
|
||||
if (parts.length !== 3) {
|
||||
return null
|
||||
}
|
||||
|
||||
let payload = JSON.parse(window.atob(parts[1]))
|
||||
if (!payload){
|
||||
return null
|
||||
}
|
||||
|
||||
let headers = JSON.parse(window.atob(parts[0]))
|
||||
if (!headers){
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
payload,
|
||||
headers,
|
||||
|
Loading…
Reference in New Issue
Block a user