-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #300 from performant-software/feature/basira294_us…
…er_permissions BASIRA #294 - User permissions
- Loading branch information
Showing
14 changed files
with
135 additions
and
54 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
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
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
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
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,55 @@ | ||
// @flow | ||
|
||
import type { Artwork } from '../types/Artwork'; | ||
import Session from './Session'; | ||
import type { PhysicalComponent } from '../types/PhysicalComponent'; | ||
import type { Document } from '../types/Document'; | ||
import type { VisualContext } from '../types/VisualContext'; | ||
|
||
class Permissions { | ||
/** | ||
* Returns `true` if the passed artwork can be deleted by the current user. | ||
* | ||
* @param artwork | ||
* | ||
* @returns {*|boolean} | ||
*/ | ||
canDeleteArtwork(artwork: Artwork) { | ||
return Session.isAdmin() || Session.getUserId() === artwork.created_by_id; | ||
} | ||
|
||
/** | ||
* Returns `true` if the passed document can be deleted by the current user. | ||
* | ||
* @param document | ||
* | ||
* @returns {*|boolean} | ||
*/ | ||
canDeleteDocument(document: Document) { | ||
return Session.isAdmin() || Session.getUserId() === document.created_by_id; | ||
} | ||
|
||
/** | ||
* Returns `true` if the passed physical component can be deleted by the current user. | ||
* | ||
* @param physicalComponent | ||
* | ||
* @returns {*|boolean} | ||
*/ | ||
canDeletePhysicalComponent(physicalComponent: PhysicalComponent) { | ||
return Session.isAdmin() || Session.getUserId() === physicalComponent.created_by_id; | ||
} | ||
|
||
/** | ||
* Returns `true` if the passed visual context can be deleted by the current user. | ||
* | ||
* @param visualContext | ||
* | ||
* @returns {*|boolean} | ||
*/ | ||
canDeleteVisualContext(visualContext: VisualContext) { | ||
return Session.isAdmin() || Session.getUserId() === visualContext.created_by_id; | ||
} | ||
} | ||
|
||
export default new Permissions(); |
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
Oops, something went wrong.