aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/oauth-model.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/server/lib/oauth-model.ts b/server/lib/oauth-model.ts
index 3adcce7b0..f13c25795 100644
--- a/server/lib/oauth-model.ts
+++ b/server/lib/oauth-model.ts
@@ -1,3 +1,4 @@
1import { AccessDeniedError} from 'oauth2-server'
1import { logger } from '../helpers/logger' 2import { logger } from '../helpers/logger'
2import { UserModel } from '../models/account/user' 3import { UserModel } from '../models/account/user'
3import { OAuthClientModel } from '../models/oauth/oauth-client' 4import { OAuthClientModel } from '../models/oauth/oauth-client'
@@ -34,6 +35,8 @@ async function getUser (usernameOrEmail: string, password: string) {
34 const passwordMatch = await user.isPasswordMatch(password) 35 const passwordMatch = await user.isPasswordMatch(password)
35 if (passwordMatch === false) return null 36 if (passwordMatch === false) return null
36 37
38 if (user.blocked) throw new AccessDeniedError('User is blocked.')
39
37 return user 40 return user
38} 41}
39 42
@@ -67,9 +70,7 @@ async function saveToken (token: TokenInfo, client: OAuthClientModel, user: User
67 } 70 }
68 71
69 const tokenCreated = await OAuthTokenModel.create(tokenToCreate) 72 const tokenCreated = await OAuthTokenModel.create(tokenToCreate)
70 const tokenToReturn = Object.assign(tokenCreated, { client, user }) 73 return Object.assign(tokenCreated, { client, user })
71
72 return tokenToReturn
73} 74}
74 75
75// --------------------------------------------------------------------------- 76// ---------------------------------------------------------------------------