mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
fix: persist OpenAI subscription expiration
This commit is contained in:
@@ -59,6 +59,20 @@ describe('useOpenAIOAuth.buildCredentials', () => {
|
||||
expect(creds.access_token).toBe('at')
|
||||
expect(creds.refresh_token).toBe('rt')
|
||||
})
|
||||
|
||||
it('should keep ChatGPT subscription expiration from token response', () => {
|
||||
const oauth = useOpenAIOAuth()
|
||||
const creds = oauth.buildCredentials({
|
||||
access_token: 'at',
|
||||
refresh_token: 'rt',
|
||||
expires_at: 1700000000,
|
||||
plan_type: 'team',
|
||||
subscription_expires_at: '2026-07-20T19:22:48+00:00'
|
||||
})
|
||||
|
||||
expect(creds.plan_type).toBe('team')
|
||||
expect(creds.subscription_expires_at).toBe('2026-07-20T19:22:48+00:00')
|
||||
})
|
||||
})
|
||||
|
||||
describe('useOpenAIOAuth.exchangeAuthCode', () => {
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface OpenAITokenInfo {
|
||||
email?: string
|
||||
name?: string
|
||||
plan_type?: string
|
||||
subscription_expires_at?: string
|
||||
privacy_mode?: string
|
||||
// OpenAI specific IDs (extracted from ID Token)
|
||||
chatgpt_account_id?: string
|
||||
@@ -197,6 +198,9 @@ export function useOpenAIOAuth() {
|
||||
if (tokenInfo.plan_type) {
|
||||
creds.plan_type = tokenInfo.plan_type
|
||||
}
|
||||
if (tokenInfo.subscription_expires_at) {
|
||||
creds.subscription_expires_at = tokenInfo.subscription_expires_at
|
||||
}
|
||||
if (tokenInfo.client_id) {
|
||||
creds.client_id = tokenInfo.client_id
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user