1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +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

@ -21,6 +21,7 @@ import { hasUserRight, USER_ROLE_LABELS, UserRight } from '../../../shared'
import { User, UserRole } from '../../../shared/models/users'
import {
isUserAutoPlayVideoValid,
isUserBlockedValid,
isUserNSFWPolicyValid,
isUserPasswordValid,
isUserRoleValid,
@ -100,6 +101,12 @@ export class UserModel extends Model<UserModel> {
@Column
autoPlayVideo: boolean
@AllowNull(false)
@Default(false)
@Is('UserBlocked', value => throwIfNotValid(value, isUserBlockedValid, 'blocked boolean'))
@Column
blocked: boolean
@AllowNull(false)
@Is('UserRole', value => throwIfNotValid(value, isUserRoleValid, 'role'))
@Column

View file

@ -3,6 +3,7 @@ import { logger } from '../../helpers/logger'
import { AccountModel } from '../account/account'
import { UserModel } from '../account/user'
import { OAuthClientModel } from './oauth-client'
import { Transaction } from 'sequelize'
export type OAuthTokenInfo = {
refreshToken: string
@ -125,7 +126,7 @@ export class OAuthTokenModel extends Model<OAuthTokenModel> {
} as OAuthTokenInfo
})
.catch(err => {
logger.info('getRefreshToken error.', { err })
logger.error('getRefreshToken error.', { err })
throw err
})
}
@ -163,11 +164,12 @@ export class OAuthTokenModel extends Model<OAuthTokenModel> {
})
}
static deleteUserToken (userId: number) {
static deleteUserToken (userId: number, t?: Transaction) {
const query = {
where: {
userId
}
},
transaction: t
}
return OAuthTokenModel.destroy(query)