diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-08 14:58:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-08 15:22:58 +0200 |
commit | e69219184b1a3262ec5e617d30337b6431c9840c (patch) | |
tree | 959b32e1ed28047052604941870563e946be9de1 /server/lib/oauth-model.ts | |
parent | 6b09aba90dfe4c61331b66b1a6ef1f58ddc61485 (diff) | |
download | PeerTube-e69219184b1a3262ec5e617d30337b6431c9840c.tar.gz PeerTube-e69219184b1a3262ec5e617d30337b6431c9840c.tar.zst PeerTube-e69219184b1a3262ec5e617d30337b6431c9840c.zip |
Implement user blocking on server side
Diffstat (limited to 'server/lib/oauth-model.ts')
-rw-r--r-- | server/lib/oauth-model.ts | 7 |
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 @@ | |||
1 | import { AccessDeniedError} from 'oauth2-server' | ||
1 | import { logger } from '../helpers/logger' | 2 | import { logger } from '../helpers/logger' |
2 | import { UserModel } from '../models/account/user' | 3 | import { UserModel } from '../models/account/user' |
3 | import { OAuthClientModel } from '../models/oauth/oauth-client' | 4 | import { 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 | // --------------------------------------------------------------------------- |