forked from premieroctet/openchakra
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sosynpl: [premieroctet#156] Allow PUT recommandation when not logged
- Loading branch information
1 parent
57c21b1
commit 4ea3774
Showing
4 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { VERB_GET, VERB_PUT } = require("../../../utils/consts") | ||
const { NotLoggedError } = require("../../utils/errors") | ||
|
||
const checkPermission = async ({verb, model, id, user}) => { | ||
console.log('Checking permission', verb, model, id, !!user) | ||
// Allow anonymous recommandation GET and PUT for one item | ||
if (!user) { | ||
if (model=='recommandation' && [VERB_GET, VERB_PUT].includes(verb) && !!id) { | ||
return | ||
} | ||
throw new NotLoggedError('Unauthorized') | ||
} | ||
} | ||
|
||
module.exports={ | ||
checkPermission, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters