fix: added missing files for change password
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
export function decodeJwtPayload<T>(token: string): T | null {
|
||||
const parts = token.split('.')
|
||||
if (parts.length !== 3) return null
|
||||
|
||||
try {
|
||||
const base64 = parts[1]!.replace(/-/g, '+').replace(/_/g, '/')
|
||||
const json = decodeURIComponent(
|
||||
atob(base64)
|
||||
.split('')
|
||||
.map((c) => '%' + c.charCodeAt(0).toString(16).padStart(2, '0'))
|
||||
.join(''),
|
||||
)
|
||||
return JSON.parse(json) as T
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user