From 005e09a43fba1ab0cf46100d76446f167b972c08 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Fri, 20 Mar 2020 18:24:48 +0100 Subject: [PATCH] Can reuse function for multiple levels --- src/entities/RequestHandler.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/entities/RequestHandler.ts b/src/entities/RequestHandler.ts index cca0641..7314757 100644 --- a/src/entities/RequestHandler.ts +++ b/src/entities/RequestHandler.ts @@ -314,10 +314,10 @@ export class RequestHandler { * * @param name The name of the POST field containing the ID of the target post */ - public async postPostIDWithAccess(name: string) : Promise { + public async postPostIDWithAccess(name: string, minLevel: PostAccessLevel = PostAccessLevel.BASIC_ACCESS) : Promise { const postID = await this.postPostID(name); - if(await PostsHelper.GetAccessLevelFromPostID(this.optionnalUserID, postID) == PostAccessLevel.NO_ACCESS) + if(await PostsHelper.GetAccessLevelFromPostID(this.optionnalUserID, postID) < minLevel) this.error(401, "Your are not allowed to access this post information!"); return postID;