diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 105c36600..b04970108 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts @@ -90,7 +90,7 @@ function isUserBlockedReasonValid (value: any) { } function isUserRoleValid (value: any) { - return exists(value) && validator.isInt('' + value) && UserRole[value] !== undefined + return exists(value) && validator.isInt('' + value) && [ UserRole.ADMINISTRATOR, UserRole.MODERATOR, UserRole.USER ].includes(value) } // --------------------------------------------------------------------------- diff --git a/shared/models/http/http-error-codes.ts b/shared/models/http/http-error-codes.ts index b2fbdfc5a..5ebff1cb5 100644 --- a/shared/models/http/http-error-codes.ts +++ b/shared/models/http/http-error-codes.ts @@ -4,7 +4,7 @@ * * WebDAV and other codes useless with regards to PeerTube are not listed. */ -export enum HttpStatusCode { +export const enum HttpStatusCode { /** * Official Documentation @ https://tools.ietf.org/html/rfc7231#section-6.2.1 diff --git a/shared/models/http/http-methods.ts b/shared/models/http/http-methods.ts index 1cfa458b9..3f4adafe2 100644 --- a/shared/models/http/http-methods.ts +++ b/shared/models/http/http-methods.ts @@ -1,5 +1,5 @@ /** HTTP request method to indicate the desired action to be performed for a given resource. */ -export enum HttpMethod { +export const enum HttpMethod { /** The CONNECT method establishes a tunnel to the server identified by the target resource. */ CONNECT = 'CONNECT', /** The DELETE method deletes the specified resource. */ diff --git a/shared/models/plugins/plugin.type.ts b/shared/models/plugins/plugin.type.ts index b6766821a..016219ceb 100644 --- a/shared/models/plugins/plugin.type.ts +++ b/shared/models/plugins/plugin.type.ts @@ -1,4 +1,4 @@ -export enum PluginType { +export const enum PluginType { PLUGIN = 1, THEME = 2 } diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts index 94413abca..687a2aa0d 100644 --- a/shared/models/users/user-role.ts +++ b/shared/models/users/user-role.ts @@ -1,5 +1,5 @@ // Keep the order -export enum UserRole { +export const enum UserRole { ADMINISTRATOR = 0, MODERATOR = 1, USER = 2