Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1x 4x 1x 1x 1x 1x | import { isSignedOutError } from '@/lib/api'
import { signOutHere } from './session'
const SIGN_IN_PATH = '/signin'
/**
* When the API refuses the token or the session (design 4.2), forget this browser's sign-in and
* go to /signin, which says why and comes back here afterwards. /signin handles its own errors.
*/
export async function handleSignedOutError(error: unknown): Promise<void> {
if (!isSignedOutError(error) || window.location.pathname === SIGN_IN_PATH) return
await signOutHere()
const { pathname, search, hash } = window.location
const query = new URLSearchParams({ redirect: `${pathname}${search}${hash}`, reason: error.code })
window.location.assign(`${SIGN_IN_PATH}?${query.toString()}`)
}
|