From e69219184b1a3262ec5e617d30337b6431c9840c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 8 Aug 2018 14:58:21 +0200 Subject: Implement user blocking on server side --- server/models/account/user.ts | 7 +++++++ server/models/oauth/oauth-token.ts | 8 +++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'server/models') diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 1b1fc5ee8..ea6d63312 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts @@ -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 { @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 diff --git a/server/models/oauth/oauth-token.ts b/server/models/oauth/oauth-token.ts index 026c30135..4c53848dc 100644 --- a/server/models/oauth/oauth-token.ts +++ b/server/models/oauth/oauth-token.ts @@ -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 { } 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 { }) } - static deleteUserToken (userId: number) { + static deleteUserToken (userId: number, t?: Transaction) { const query = { where: { userId - } + }, + transaction: t } return OAuthTokenModel.destroy(query) -- cgit v1.2.3