aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/oauth
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/oauth')
-rw-r--r--server/models/oauth/oauth-client.ts4
-rw-r--r--server/models/oauth/oauth-token.ts22
2 files changed, 14 insertions, 12 deletions
diff --git a/server/models/oauth/oauth-client.ts b/server/models/oauth/oauth-client.ts
index b4a841edd..42c59bb79 100644
--- a/server/models/oauth/oauth-client.ts
+++ b/server/models/oauth/oauth-client.ts
@@ -24,10 +24,10 @@ export class OAuthClientModel extends Model<OAuthClientModel> {
24 @Column 24 @Column
25 clientSecret: string 25 clientSecret: string
26 26
27 @Column({ type: DataType.ARRAY(DataType.STRING) }) // FIXME: sequelize typings 27 @Column(DataType.ARRAY(DataType.STRING))
28 grants: string[] 28 grants: string[]
29 29
30 @Column({ type: DataType.ARRAY(DataType.STRING) }) // FIXME: sequelize typings 30 @Column(DataType.ARRAY(DataType.STRING))
31 redirectUris: string[] 31 redirectUris: string[]
32 32
33 @CreatedAt 33 @CreatedAt
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) {