fix: auto logout on stale token (#144)
This commit is contained in:
parent
2d16c4868e
commit
94f2f95bcf
3 changed files with 35 additions and 5 deletions
|
@ -4,12 +4,17 @@ import { DEFAULT_SERVER } from '~/constants'
|
|||
|
||||
export default defineNuxtPlugin(async () => {
|
||||
try {
|
||||
const accessToken = currentUser.value?.token
|
||||
|
||||
// TODO: improve upstream to make this synchronous (delayed auth)
|
||||
const masto = await login({
|
||||
url: `https://${currentUser.value?.server || DEFAULT_SERVER}`,
|
||||
accessToken: currentUser.value?.token || undefined,
|
||||
accessToken,
|
||||
})
|
||||
|
||||
if (accessToken)
|
||||
masto.accounts.verifyCredentials().catch(() => signout())
|
||||
|
||||
return {
|
||||
provide: {
|
||||
masto,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue