Skip to content

Commit

Permalink
fix(auth): correct ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
dargmuesli committed Aug 23, 2022
1 parent d62ac8c commit ea51469
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nuxt/plugins/util/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ export function useJwtRefresh() {
export async function jwtStore(
$urqlReset: () => void,
store: Store,
res: ServerResponse,
res: ServerResponse | undefined,
jwt: string | undefined,
callback = () => {
window.location.reload()
}
) {
debugger
$urqlReset()

consola.trace('Storing the following JWT: ' + jwt)
Expand Down Expand Up @@ -161,15 +162,21 @@ export function useJwtStore() {

return {
async jwtStore(jwt: string | undefined, callback?: () => void) {
await jwtStore($urqlReset, store, event.res, jwt, callback)
await jwtStore(
$urqlReset,
store,
process.server ? event.res : undefined,
jwt,
callback
)
},
}
}

export async function signOut(
$urqlReset: () => void,
store: Store,
res: ServerResponse
res: ServerResponse | undefined
) {
await jwtStore($urqlReset, store, res, undefined)
}
Expand All @@ -181,7 +188,7 @@ export function useSignOut() {

return {
async signOut() {
await signOut($urqlReset, store, event.res)
await signOut($urqlReset, store, process.server ? event.res : undefined)
},
}
}

0 comments on commit ea51469

Please sign in to comment.