Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change cc-nx-g expiry to 30 days #1342

Merged
merged 1 commit into from
Jul 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/commerce-sdk-react/src/auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ class Auth {
private shopperCustomersClient: ShopperCustomers<ApiClientConfigParams>
private redirectURI: string
private pendingToken: Promise<TokenResponse> | undefined
private REFRESH_TOKEN_EXPIRATION_DAYS = 90
private REFRESH_TOKEN_EXPIRATION_DAYS_REGISTERED = 90
private REFRESH_TOKEN_EXPIRATION_DAYS_GUEST = 30
private stores: Record<StorageType, BaseStorage>
private fetchedToken: string
private OCAPISessionsURL: string
Expand Down Expand Up @@ -315,11 +316,15 @@ class Auth {
? 'refresh_token_guest_copy'
: 'refresh_token_registered_copy'

const refreshTokenExpiry = isGuest
? this.REFRESH_TOKEN_EXPIRATION_DAYS_GUEST
: this.REFRESH_TOKEN_EXPIRATION_DAYS_REGISTERED

this.set(refreshTokenKey, res.refresh_token, {
expires: this.REFRESH_TOKEN_EXPIRATION_DAYS
expires: refreshTokenExpiry
})
this.set(refreshTokenCopyKey, res.refresh_token, {
expires: this.REFRESH_TOKEN_EXPIRATION_DAYS
expires: refreshTokenExpiry
})
}

Expand Down