File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change 1
1
import NextAuth from 'next-auth'
2
2
import axios from 'axios'
3
+ // TODO(alishaevn): use the api value from https://github.com/assaydepot/rx/issues/21497 in the next phase
4
+ import { EXPIRATION_DURATION } from '../../../utils'
3
5
4
6
// For more information on each option (and a full list of options) go to: https://next-auth.js.org/configuration/options
5
7
const authOptions = {
@@ -32,6 +34,7 @@ const authOptions = {
32
34
if ( account && user ) {
33
35
return {
34
36
accessToken : account . access_token ,
37
+ accessTokenExpires : Date . now ( ) + EXPIRATION_DURATION ,
35
38
refreshToken : account . refresh_token ,
36
39
user,
37
40
}
@@ -80,6 +83,7 @@ const refreshAccessToken = async (token) => {
80
83
return {
81
84
...token ,
82
85
accessToken : refreshedTokens . access_token ,
86
+ accessTokenExpires : Date . now ( ) + EXPIRATION_DURATION ,
83
87
refreshToken : refreshedTokens . refresh_token ?? token . refreshToken , // Fall back to the old refresh token
84
88
}
85
89
} catch ( error ) {
Original file line number Diff line number Diff line change @@ -103,3 +103,8 @@ export const NAVIGATION_LINKS = [
103
103
// change this to '/services' to have this link to a page for an individual service.
104
104
// if you choose to go this route, you can update the content for the service's page at pages/services/[ware].js
105
105
export const FEATURED_SERVICE_PATH = '/requests/new'
106
+
107
+ // TODO(alishaevn): use the api value from https://github.com/assaydepot/rx/issues/21497 in the next phase
108
+ // this amount, listed in milliseconds, represents when the access token will expire
109
+ // the default is 1 week
110
+ export const EXPIRATION_DURATION = 604800000
You can’t perform that action at this time.
0 commit comments