diff options
Diffstat (limited to 'server/lib/oauth-model.ts')
-rw-r--r-- | server/lib/oauth-model.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts index 3f8b8e618..75aee2567 100644 --- a/server/lib/oauth-model.ts +++ b/server/lib/oauth-model.ts | |||
@@ -4,7 +4,7 @@ import { logger } from '../helpers/logger' | |||
4 | import { UserModel } from '../models/account/user' | 4 | import { UserModel } from '../models/account/user' |
5 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 5 | import { OAuthClientModel } from '../models/oauth/oauth-client' |
6 | import { OAuthTokenModel } from '../models/oauth/oauth-token' | 6 | import { OAuthTokenModel } from '../models/oauth/oauth-token' |
7 | import { LRU_CACHE } from '../initializers/constants' | 7 | import { LRU_CACHE, OAUTH_LIFETIME } from '../initializers/constants' |
8 | import { Transaction } from 'sequelize' | 8 | import { Transaction } from 'sequelize' |
9 | import { CONFIG } from '../initializers/config' | 9 | import { CONFIG } from '../initializers/config' |
10 | import * as LRUCache from 'lru-cache' | 10 | import * as LRUCache from 'lru-cache' |
@@ -192,7 +192,15 @@ async function saveToken (token: TokenInfo, client: OAuthClientModel, user: User | |||
192 | user.lastLoginDate = new Date() | 192 | user.lastLoginDate = new Date() |
193 | await user.save() | 193 | await user.save() |
194 | 194 | ||
195 | return Object.assign(tokenCreated, { client, user }) | 195 | return { |
196 | accessToken: tokenCreated.accessToken, | ||
197 | accessTokenExpiresAt: tokenCreated.accessTokenExpiresAt, | ||
198 | refreshToken: tokenCreated.refreshToken, | ||
199 | refreshTokenExpiresAt: tokenCreated.refreshTokenExpiresAt, | ||
200 | client, | ||
201 | user, | ||
202 | refresh_token_expires_in: Math.floor((tokenCreated.refreshTokenExpiresAt.getTime() - new Date().getTime()) / 1000) | ||
203 | } | ||
196 | } | 204 | } |
197 | 205 | ||
198 | // --------------------------------------------------------------------------- | 206 | // --------------------------------------------------------------------------- |