1
0
mirror of https://gitlab.com/comunic/comunicapiv2 synced 2024-12-28 14:38:52 +00:00

Can reuse function for multiple levels

This commit is contained in:
Pierre HUBERT 2020-03-20 18:24:48 +01:00
parent 4066b2c6d3
commit 005e09a43f

View File

@ -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<number> {
public async postPostIDWithAccess(name: string, minLevel: PostAccessLevel = PostAccessLevel.BASIC_ACCESS) : Promise<number> {
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;