From f8cdb1289248e90000e2aeac823ebd84531c7c0f Mon Sep 17 00:00:00 2001 From: bmccandless Date: Wed, 26 Aug 2020 13:01:50 -0700 Subject: [PATCH] Fix frontend mishandling of null userinfo (#1795) * Fix frontend mishandling of null userinfo If the authentication is disabled, the userinfo endpoint returns null. This case needs to be handled. #1780 * Small fix for handling refesh tokens in auth --- client/src/actions/index.js | 2 +- server/auth/auth_oauth.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/actions/index.js b/client/src/actions/index.js index 4c39f86d..8730730e 100644 --- a/client/src/actions/index.js +++ b/client/src/actions/index.js @@ -43,7 +43,7 @@ async function configFetch(dispatch) { async function userInfoFetch(dispatch) { return fetchJson("userinfo").then((response) => { - const userinfo = { ...response.userinfo }; + const { userinfo } = response || {}; dispatch({ type: "userinfo load complete", userinfo, diff --git a/server/auth/auth_oauth.py b/server/auth/auth_oauth.py index 084d1af9..428d0048 100644 --- a/server/auth/auth_oauth.py +++ b/server/auth/auth_oauth.py @@ -29,7 +29,9 @@ class Tokens: self.id_token = id_token self.refresh_token = refresh_token self.expires_at = expires_at - if not (access_token and id_token and refresh_token and expires_at): + + # expires_at may be None after a token refresh, and so it is not checked here + if not (access_token and id_token and refresh_token): raise KeyError(str(self.__dict__))