mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-03 18:52:17 +00:00
fix(gitlab): handle missing expires_in in OAuth token response
Some self-hosted GitLab instances (e.g. older versions without expires_in configured in doorkeeper) omit expires_in from the OAuth token response. Computing Date.now()/1000 + undefined produced NaN, which Postgres rejected on the expires_at integer column, crashing both the initial OAuth callback and the token refresh flow with a 500. Falls back to null when expires_in is absent, matching the existing Gitea callback behavior. Closes #4362
This commit is contained in:
@@ -53,7 +53,9 @@ export default async function handler(
|
|||||||
return res.status(400).json({ error: "Missing or invalid code" });
|
return res.status(400).json({ error: "Missing or invalid code" });
|
||||||
}
|
}
|
||||||
|
|
||||||
const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in;
|
const expiresAt = result.expires_in
|
||||||
|
? Math.floor(Date.now() / 1000) + result.expires_in
|
||||||
|
: null;
|
||||||
await updateGitlab(gitlab.gitlabId, {
|
await updateGitlab(gitlab.gitlabId, {
|
||||||
accessToken: result.access_token,
|
accessToken: result.access_token,
|
||||||
refreshToken: result.refresh_token,
|
refreshToken: result.refresh_token,
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ export const refreshGitlabToken = async (gitlabProviderId: string) => {
|
|||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
const expiresAt = Math.floor(Date.now() / 1000) + data.expires_in;
|
const expiresAt = data.expires_in
|
||||||
|
? Math.floor(Date.now() / 1000) + data.expires_in
|
||||||
|
: null;
|
||||||
|
|
||||||
await updateGitlab(gitlabProviderId, {
|
await updateGitlab(gitlabProviderId, {
|
||||||
accessToken: data.access_token,
|
accessToken: data.access_token,
|
||||||
|
|||||||
Reference in New Issue
Block a user