Select account redesign (#8905)

* new designs for select account

* tweak web styles

* add logged out indicator

* unify helper function

* move error, try catch
This commit is contained in:
Samuel Newman
2025-11-10 16:02:53 +02:00
committed by GitHub
parent 4791486aa7
commit ad91029f10
5 changed files with 90 additions and 39 deletions
+23
View File
@@ -0,0 +1,23 @@
import {jwtDecode} from 'jwt-decode'
import {logger} from '#/logger'
/**
* Simple check if a JWT token has expired. Does *not* validate the token or check for revocation status,
* just checks the expiration time.
*
* @param token The JWT token to check.
* @returns `true` if the token has expired, `false` otherwise.
*/
export function isJwtExpired(token: string) {
try {
const payload = jwtDecode(token)
if (!payload.exp) return true
const now = Math.floor(Date.now() / 1000)
return now >= payload.exp
} catch {
logger.error(`session: could not decode jwt`)
return true // invalid token or parse error
}
}