aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/oauth-model.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-08 14:58:21 +0200
committerChocobozzz <me@florianbigard.com>2018-08-08 15:22:58 +0200
commite69219184b1a3262ec5e617d30337b6431c9840c (patch)
tree959b32e1ed28047052604941870563e946be9de1 /server/lib/oauth-model.ts
parent6b09aba90dfe4c61331b66b1a6ef1f58ddc61485 (diff)
downloadPeerTube-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.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// ---------------------------------------------------------------------------