Skip to content

Commit

Permalink
fix: added useStorage optional chaining and types
Browse files Browse the repository at this point in the history
  • Loading branch information
DallasHoff authored Apr 18, 2024
1 parent 930b6d7 commit 090320e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/runtime/server/utils/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ export async function clearUserSession(event: H3Event) {

export async function refreshUserSession(event: H3Event) {
const session = await _useSession(event)
const persistentSession = await useStorage('oidc').getItem<PersistentSession>(session.id as string) as PersistentSession
const persistentSession = await useStorage('oidc').getItem<PersistentSession>(session.id as string) as PersistentSession | null

if (!session.data.canRefresh || !persistentSession.refreshToken) {
if (!session.data.canRefresh || !persistentSession?.refreshToken) {
throw createError({
statusCode: 500,
message: 'No refresh token'
Expand Down Expand Up @@ -110,7 +110,7 @@ export async function requireUserSession(event: H3Event) {
// Expiration check
if (sessionConfig.expirationCheck) {
const sessionId = await getUserSessionId(event)
const persistentSession = await useStorage('oidc').getItem<PersistentSession>(sessionId as string) as PersistentSession
const persistentSession = await useStorage('oidc').getItem<PersistentSession>(sessionId as string) as PersistentSession | null
if (!persistentSession)
logger.warn('Persistent user session not found')

Expand Down

0 comments on commit 090320e

Please sign in to comment.