diff --git a/server/models/UserAuthentication.ts b/server/models/UserAuthentication.ts index 37dde8322..ee3433b4f 100644 --- a/server/models/UserAuthentication.ts +++ b/server/models/UserAuthentication.ts @@ -142,7 +142,13 @@ class UserAuthentication extends IdModel { authenticationProvider: AuthenticationProvider, options: SaveOptions ): Promise { - if (this.expiresAt > addMinutes(Date.now(), 5) || !this.refreshToken) { + if ( + this.expiresAt > addMinutes(Date.now(), 5) || + !this.refreshToken || + // Some providers send no expiry depending on setup, in this case we can't + // refresh and assume the session is valid until logged out. + !this.expiresAt + ) { return false; } @@ -162,7 +168,7 @@ class UserAuthentication extends IdModel { } this.accessToken = response.accessToken; this.expiresAt = response.expiresAt; - this.save(options); + await this.save(options); } Logger.info("utils", "Successfully refreshed expired access token", {