aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/auth.ts1
-rw-r--r--server/lib/oauth-model.ts12
2 files changed, 11 insertions, 2 deletions
diff --git a/server/lib/auth.ts b/server/lib/auth.ts
index 466c9bdd4..dbd421a7b 100644
--- a/server/lib/auth.ts
+++ b/server/lib/auth.ts
@@ -19,6 +19,7 @@ const oAuthServer = new OAuthServer({
19 useErrorHandler: true, 19 useErrorHandler: true,
20 accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN, 20 accessTokenLifetime: OAUTH_LIFETIME.ACCESS_TOKEN,
21 refreshTokenLifetime: OAUTH_LIFETIME.REFRESH_TOKEN, 21 refreshTokenLifetime: OAUTH_LIFETIME.REFRESH_TOKEN,
22 allowExtendedTokenAttributes: true,
22 continueMiddleware: true, 23 continueMiddleware: true,
23 model: require('./oauth-model') 24 model: require('./oauth-model')
24}) 25})
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// ---------------------------------------------------------------------------