1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-03 17:59:37 +02:00

Implement user blocking on server side

This commit is contained in:
Chocobozzz 2018-08-08 14:58:21 +02:00
parent 6b09aba90d
commit e69219184b
No known key found for this signature in database
GPG key ID: 583A612D890159BE
15 changed files with 287 additions and 59 deletions

View file

@ -1,3 +1,4 @@
import { AccessDeniedError} from 'oauth2-server'
import { logger } from '../helpers/logger'
import { UserModel } from '../models/account/user'
import { OAuthClientModel } from '../models/oauth/oauth-client'
@ -34,6 +35,8 @@ async function getUser (usernameOrEmail: string, password: string) {
const passwordMatch = await user.isPasswordMatch(password)
if (passwordMatch === false) return null
if (user.blocked) throw new AccessDeniedError('User is blocked.')
return user
}
@ -67,9 +70,7 @@ async function saveToken (token: TokenInfo, client: OAuthClientModel, user: User
}
const tokenCreated = await OAuthTokenModel.create(tokenToCreate)
const tokenToReturn = Object.assign(tokenCreated, { client, user })
return tokenToReturn
return Object.assign(tokenCreated, { client, user })
}
// ---------------------------------------------------------------------------