mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2024-11-25 23:09:22 +00:00
Can reuse function for multiple levels
This commit is contained in:
parent
4066b2c6d3
commit
005e09a43f
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user