From 954605a804da399317ca62afa2fb9244afa11ebf Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Oct 2017 16:55:03 +0200 Subject: Support roles with rights and add moderator role --- client/src/app/shared/forms/form-validators/user.ts | 6 ++++++ client/src/app/shared/users/user.model.ts | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/forms/form-validators/user.ts b/client/src/app/shared/forms/form-validators/user.ts index d4c4c1d33..e7473b75b 100644 --- a/client/src/app/shared/forms/form-validators/user.ts +++ b/client/src/app/shared/forms/form-validators/user.ts @@ -29,3 +29,9 @@ export const USER_VIDEO_QUOTA = { 'min': 'Quota must be greater than -1.' } } +export const USER_ROLE = { + VALIDATORS: [ Validators.required ], + MESSAGES: { + 'required': 'User role is required.', + } +} diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 7beea5910..d738899ab 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts @@ -1,7 +1,9 @@ import { User as UserServerModel, UserRole, - VideoChannel + VideoChannel, + UserRight, + hasUserRight } from '../../../../../shared' export type UserConstructorHash = { @@ -56,7 +58,7 @@ export class User implements UserServerModel { } } - isAdmin () { - return this.role === 'admin' + hasRight (right: UserRight) { + return hasUserRight(this.role, right) } } -- cgit v1.2.3