fix: Handle GitLab can be configured for tokens to not expire. (#4051)

closes #4040
This commit is contained in:
Tom Moor
2022-09-04 12:56:00 +02:00
committed by GitHub
parent c9156ae399
commit c964163cc5

View File

@@ -142,7 +142,13 @@ class UserAuthentication extends IdModel {
authenticationProvider: AuthenticationProvider,
options: SaveOptions
): Promise<boolean> {
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", {