From 89da4e1e2bad2edfd031e657cabd2ab78d37a495 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 1 May 2021 23:49:42 +0200 Subject: [PATCH] :bug: (github login) --- src/hooks/useGitHubLogin.hook.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/hooks/useGitHubLogin.hook.ts b/src/hooks/useGitHubLogin.hook.ts index 814f17f..f378347 100644 --- a/src/hooks/useGitHubLogin.hook.ts +++ b/src/hooks/useGitHubLogin.hook.ts @@ -34,22 +34,26 @@ export const useGitHubLogin = () => { const saveCredentials = async (githubToken: GithubToken) => { const actualPAT = await getAccessToken() + const expirationDate = addMilliseconds( + new Date(), + githubToken.expires_in + ).toISOString() + + const refreshTokenExpirationDate = addMilliseconds( + new Date(), + githubToken.refresh_token_expires_in + ).toISOString() + const accessToken: GithubAccessToken = { ...actualPAT, _id: data.generateId(DataType.GithubAccessToken, personalTokenId), $type: DataType.GithubAccessToken, token: githubToken.access_token, expiresIn: githubToken.expires_in, - expirationDate: addMilliseconds( - new Date(), - githubToken.expires_in - ).toISOString(), + expirationDate, refreshToken: githubToken.refresh_token, refreshTokenExpiresIn: githubToken.refresh_token_expires_in, - refreshTokenExpirationDate: addMilliseconds( - new Date(), - githubToken.refresh_token_expires_in - ).toISOString(), + refreshTokenExpirationDate, username: '' }