diff options
Diffstat (limited to 'server/models/oauth/oauth-token.ts')
-rw-r--r-- | server/models/oauth/oauth-token.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/server/models/oauth/oauth-token.ts b/server/models/oauth/oauth-token.ts index 3f41ee63b..903d551df 100644 --- a/server/models/oauth/oauth-token.ts +++ b/server/models/oauth/oauth-token.ts | |||
@@ -34,30 +34,30 @@ enum ScopeNames { | |||
34 | WITH_USER = 'WITH_USER' | 34 | WITH_USER = 'WITH_USER' |
35 | } | 35 | } |
36 | 36 | ||
37 | @Scopes({ | 37 | @Scopes(() => ({ |
38 | [ScopeNames.WITH_USER]: { | 38 | [ScopeNames.WITH_USER]: { |
39 | include: [ | 39 | include: [ |
40 | { | 40 | { |
41 | model: () => UserModel.unscoped(), | 41 | model: UserModel.unscoped(), |
42 | required: true, | 42 | required: true, |
43 | include: [ | 43 | include: [ |
44 | { | 44 | { |
45 | attributes: [ 'id' ], | 45 | attributes: [ 'id' ], |
46 | model: () => AccountModel.unscoped(), | 46 | model: AccountModel.unscoped(), |
47 | required: true, | 47 | required: true, |
48 | include: [ | 48 | include: [ |
49 | { | 49 | { |
50 | attributes: [ 'id', 'url' ], | 50 | attributes: [ 'id', 'url' ], |
51 | model: () => ActorModel.unscoped(), | 51 | model: ActorModel.unscoped(), |
52 | required: true | 52 | required: true |
53 | } | 53 | } |
54 | ] | 54 | ] |
55 | } | 55 | } |
56 | ] | 56 | ] |
57 | } | 57 | } |
58 | ] as any // FIXME: sequelize typings | 58 | ] |
59 | } | 59 | } |
60 | }) | 60 | })) |
61 | @Table({ | 61 | @Table({ |
62 | tableName: 'oAuthToken', | 62 | tableName: 'oAuthToken', |
63 | indexes: [ | 63 | indexes: [ |
@@ -167,11 +167,13 @@ export class OAuthTokenModel extends Model<OAuthTokenModel> { | |||
167 | } | 167 | } |
168 | } | 168 | } |
169 | 169 | ||
170 | return OAuthTokenModel.scope(ScopeNames.WITH_USER).findOne(query).then(token => { | 170 | return OAuthTokenModel.scope(ScopeNames.WITH_USER) |
171 | if (token) token['user'] = token.User | 171 | .findOne(query) |
172 | .then(token => { | ||
173 | if (token) token[ 'user' ] = token.User | ||
172 | 174 | ||
173 | return token | 175 | return token |
174 | }) | 176 | }) |
175 | } | 177 | } |
176 | 178 | ||
177 | static getByRefreshTokenAndPopulateUser (refreshToken: string) { | 179 | static getByRefreshTokenAndPopulateUser (refreshToken: string) { |