Moving authorization to utils

This commit is contained in:
Matthew Dillon 2015-07-04 11:34:31 -07:00
parent 1c47941413
commit cdc825cc6a
7 changed files with 38 additions and 13 deletions

View file

@ -0,0 +1,3 @@
export default function userCanAdd(role) {
return (role === 'W') || (role === 'A');
}

View file

@ -0,0 +1,5 @@
export default function userCanEdit(currentUser, author) {
let id = currentUser.id;
let role = currentUser.role;
return (role === 'W' && (+id === author)) || (role === 'A');
}