🐛 (sign ing) update expiration date
This commit is contained in:
@@ -4,7 +4,7 @@ import { GithubAccessToken } from '@/data/models/GithubAccessToken'
|
|||||||
import { GithubToken } from '@/modules/user/interfaces/GithubToken'
|
import { GithubToken } from '@/modules/user/interfaces/GithubToken'
|
||||||
import { GithubTokenError } from '@/modules/user/interfaces/GithubTokenError'
|
import { GithubTokenError } from '@/modules/user/interfaces/GithubTokenError'
|
||||||
import { Octokit } from '@octokit/rest'
|
import { Octokit } from '@octokit/rest'
|
||||||
import { addMilliseconds } from 'date-fns'
|
import { addSeconds } from 'date-fns'
|
||||||
|
|
||||||
const AUTHENTICATION_SERVER = 'https://litenote.li212.fr'
|
const AUTHENTICATION_SERVER = 'https://litenote.li212.fr'
|
||||||
const personalTokenId = 'token'
|
const personalTokenId = 'token'
|
||||||
@@ -34,7 +34,7 @@ export const refreshToken = async () => {
|
|||||||
console.log(
|
console.log(
|
||||||
new Date(accessToken.expirationDate) >= new Date(),
|
new Date(accessToken.expirationDate) >= new Date(),
|
||||||
accessToken.expirationDate,
|
accessToken.expirationDate,
|
||||||
new Date()
|
accessToken
|
||||||
)
|
)
|
||||||
|
|
||||||
if (new Date(accessToken.expirationDate) >= new Date()) {
|
if (new Date(accessToken.expirationDate) >= new Date()) {
|
||||||
@@ -47,6 +47,8 @@ export const refreshToken = async () => {
|
|||||||
| GithubToken
|
| GithubToken
|
||||||
| GithubTokenError
|
| GithubTokenError
|
||||||
|
|
||||||
|
console.log(response)
|
||||||
|
|
||||||
if ('error' in githubToken) {
|
if ('error' in githubToken) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -69,12 +71,12 @@ export const getAccessToken = async () => {
|
|||||||
export const saveAccessToken = async (githubToken: GithubToken) => {
|
export const saveAccessToken = async (githubToken: GithubToken) => {
|
||||||
const actualPAT = await getAccessToken()
|
const actualPAT = await getAccessToken()
|
||||||
|
|
||||||
const expirationDate = addMilliseconds(
|
const expirationDate = addSeconds(
|
||||||
new Date(),
|
new Date(),
|
||||||
githubToken.expires_in
|
githubToken.expires_in
|
||||||
).toISOString()
|
).toISOString()
|
||||||
|
|
||||||
const refreshTokenExpirationDate = addMilliseconds(
|
const refreshTokenExpirationDate = addSeconds(
|
||||||
new Date(),
|
new Date(),
|
||||||
githubToken.refresh_token_expires_in
|
githubToken.refresh_token_expires_in
|
||||||
).toISOString()
|
).toISOString()
|
||||||
|
|||||||
Reference in New Issue
Block a user