From c718b396e074070a035ce142a6590d504b9e896d Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Fri, 12 Aug 2022 14:58:32 -0700 Subject: [PATCH] Tweak server auth to return `null` instead of `undefined` --- web/lib/firebase/server-auth.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/web/lib/firebase/server-auth.ts b/web/lib/firebase/server-auth.ts index 8e5336c8..d9729ca4 100644 --- a/web/lib/firebase/server-auth.ts +++ b/web/lib/firebase/server-auth.ts @@ -81,7 +81,7 @@ const authAndRefreshTokens = async (ctx: RequestContext) => { // step 0: if you have no refresh token you are logged out if (refresh == null) { console.debug('User is unauthenticated.') - return undefined + return null } console.debug('User may be authenticated; checking cookies.') @@ -107,7 +107,7 @@ const authAndRefreshTokens = async (ctx: RequestContext) => { } catch (e) { // big unexpected problem -- functionally, they are not logged in console.error(e) - return undefined + return null } } @@ -136,9 +136,10 @@ const authAndRefreshTokens = async (ctx: RequestContext) => { } catch (e) { // big unexpected problem -- functionally, they are not logged in console.error(e) - return undefined + return null } } + return null } export const authenticateOnServer = async (ctx: RequestContext) => { @@ -158,7 +159,7 @@ export const authenticateOnServer = async (ctx: RequestContext) => { // definitely not supposed to happen, but let's be maximally robust console.error(e) } - return creds + return creds ?? null } // note that we might want to define these types more generically if we want better