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:
parent
6b09aba90d
commit
e69219184b
15 changed files with 287 additions and 59 deletions
|
@ -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 })
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue