Skip to content

Commit

Permalink
feat(session): save provider access/refresh tokens in cookies (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitjans committed Jul 3, 2023
1 parent cd3bc0f commit ea8c21f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/runtime/server/api/session.ts
Expand Up @@ -27,6 +27,24 @@ export default defineEventHandler(async (event) => {
path: cookieOptions.path,
sameSite: cookieOptions.sameSite as boolean | 'lax' | 'strict' | 'none'
})

if (session.provider_token) {
setCookie(event, `${cookieOptions.name}-provider-token`, session.provider_token, {
domain: cookieOptions.domain,
maxAge: cookieOptions.lifetime ?? 0,
path: cookieOptions.path,
sameSite: cookieOptions.sameSite as boolean | 'lax' | 'strict' | 'none'
})
}

if (session.provider_refresh_token) {
setCookie(event, `${cookieOptions.name}-provider-refresh-token`, session.provider_refresh_token, {
domain: cookieOptions.domain,
maxAge: cookieOptions.lifetime ?? 0,
path: cookieOptions.path,
sameSite: cookieOptions.sameSite as boolean | 'lax' | 'strict' | 'none'
})
}
}

if (signEvent === 'SIGNED_OUT') {
Expand Down

0 comments on commit ea8c21f

Please sign in to comment.