aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/oauth-model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/oauth-model.ts')
-rw-r--r--server/lib/oauth-model.ts12
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'
4import { UserModel } from '../models/account/user' 4import { UserModel } from '../models/account/user'
5import { OAuthClientModel } from '../models/oauth/oauth-client' 5import { OAuthClientModel } from '../models/oauth/oauth-client'
6import { OAuthTokenModel } from '../models/oauth/oauth-token' 6import { OAuthTokenModel } from '../models/oauth/oauth-token'
7import { LRU_CACHE } from '../initializers/constants' 7import { LRU_CACHE, OAUTH_LIFETIME } from '../initializers/constants'
8import { Transaction } from 'sequelize' 8import { Transaction } from 'sequelize'
9import { CONFIG } from '../initializers/config' 9import { CONFIG } from '../initializers/config'
10import * as LRUCache from 'lru-cache' 10import * 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// ---------------------------------------------------------------------------