diff options
Diffstat (limited to 'server/models/oauth')
-rw-r--r-- | server/models/oauth/oauth-token-interface.ts | 5 | ||||
-rw-r--r-- | server/models/oauth/oauth-token.ts | 22 |
2 files changed, 3 insertions, 24 deletions
diff --git a/server/models/oauth/oauth-token-interface.ts b/server/models/oauth/oauth-token-interface.ts index ef97893c4..47d95d5fc 100644 --- a/server/models/oauth/oauth-token-interface.ts +++ b/server/models/oauth/oauth-token-interface.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import * as Promise from 'bluebird' | 1 | import * as Promise from 'bluebird' |
2 | import * as Sequelize from 'sequelize' | ||
3 | 3 | ||
4 | import { UserModel } from '../account/user-interface' | 4 | import { UserModel } from '../account/user-interface' |
5 | 5 | ||
@@ -18,15 +18,12 @@ export namespace OAuthTokenMethods { | |||
18 | export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Promise<OAuthTokenInfo> | 18 | export type GetByRefreshTokenAndPopulateClient = (refreshToken: string) => Promise<OAuthTokenInfo> |
19 | export type GetByTokenAndPopulateUser = (bearerToken: string) => Promise<OAuthTokenInstance> | 19 | export type GetByTokenAndPopulateUser = (bearerToken: string) => Promise<OAuthTokenInstance> |
20 | export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Promise<OAuthTokenInstance> | 20 | export type GetByRefreshTokenAndPopulateUser = (refreshToken: string) => Promise<OAuthTokenInstance> |
21 | |||
22 | export type RemoveByUserId = (userId) => Promise<number> | ||
23 | } | 21 | } |
24 | 22 | ||
25 | export interface OAuthTokenClass { | 23 | export interface OAuthTokenClass { |
26 | getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient | 24 | getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient |
27 | getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser | 25 | getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser |
28 | getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser | 26 | getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser |
29 | removeByUserId: OAuthTokenMethods.RemoveByUserId | ||
30 | } | 27 | } |
31 | 28 | ||
32 | export interface OAuthTokenAttributes { | 29 | export interface OAuthTokenAttributes { |
diff --git a/server/models/oauth/oauth-token.ts b/server/models/oauth/oauth-token.ts index c7afcc38c..a82bff130 100644 --- a/server/models/oauth/oauth-token.ts +++ b/server/models/oauth/oauth-token.ts | |||
@@ -3,19 +3,12 @@ import * as Sequelize from 'sequelize' | |||
3 | import { logger } from '../../helpers' | 3 | import { logger } from '../../helpers' |
4 | 4 | ||
5 | import { addMethodsToModel } from '../utils' | 5 | import { addMethodsToModel } from '../utils' |
6 | import { | 6 | import { OAuthTokenAttributes, OAuthTokenInfo, OAuthTokenInstance, OAuthTokenMethods } from './oauth-token-interface' |
7 | OAuthTokenInstance, | ||
8 | OAuthTokenAttributes, | ||
9 | |||
10 | OAuthTokenMethods, | ||
11 | OAuthTokenInfo | ||
12 | } from './oauth-token-interface' | ||
13 | 7 | ||
14 | let OAuthToken: Sequelize.Model<OAuthTokenInstance, OAuthTokenAttributes> | 8 | let OAuthToken: Sequelize.Model<OAuthTokenInstance, OAuthTokenAttributes> |
15 | let getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient | 9 | let getByRefreshTokenAndPopulateClient: OAuthTokenMethods.GetByRefreshTokenAndPopulateClient |
16 | let getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser | 10 | let getByTokenAndPopulateUser: OAuthTokenMethods.GetByTokenAndPopulateUser |
17 | let getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser | 11 | let getByRefreshTokenAndPopulateUser: OAuthTokenMethods.GetByRefreshTokenAndPopulateUser |
18 | let removeByUserId: OAuthTokenMethods.RemoveByUserId | ||
19 | 12 | ||
20 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { | 13 | export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) { |
21 | OAuthToken = sequelize.define<OAuthTokenInstance, OAuthTokenAttributes>('OAuthToken', | 14 | OAuthToken = sequelize.define<OAuthTokenInstance, OAuthTokenAttributes>('OAuthToken', |
@@ -62,8 +55,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
62 | 55 | ||
63 | getByRefreshTokenAndPopulateClient, | 56 | getByRefreshTokenAndPopulateClient, |
64 | getByTokenAndPopulateUser, | 57 | getByTokenAndPopulateUser, |
65 | getByRefreshTokenAndPopulateUser, | 58 | getByRefreshTokenAndPopulateUser |
66 | removeByUserId | ||
67 | ] | 59 | ] |
68 | addMethodsToModel(OAuthToken, classMethods) | 60 | addMethodsToModel(OAuthToken, classMethods) |
69 | 61 | ||
@@ -170,13 +162,3 @@ getByRefreshTokenAndPopulateUser = function (refreshToken: string) { | |||
170 | return token | 162 | return token |
171 | }) | 163 | }) |
172 | } | 164 | } |
173 | |||
174 | removeByUserId = function (userId: number) { | ||
175 | const query = { | ||
176 | where: { | ||
177 | userId: userId | ||
178 | } | ||
179 | } | ||
180 | |||
181 | return OAuthToken.destroy(query) | ||
182 | } | ||