-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
122 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"admin": { | ||
"accessReviews": true, | ||
"accessUsers": true, | ||
"resetReviews": true, | ||
"accessTransactions": true, | ||
"accessAdminNav": true, | ||
"submitToOwnRepo": true | ||
}, | ||
"evaluator": { | ||
"accessReviews": true, | ||
"accessUsers": false, | ||
"resetReviews": false, | ||
"accessTransactions": false, | ||
"accessAdminNav": true, | ||
"submitToOwnRepo": false | ||
}, | ||
"reviewer": { | ||
"accessReviews": false, | ||
"accessUsers": false, | ||
"resetReviews": false, | ||
"accessTransactions": false, | ||
"accessAdminNav": false, | ||
"submitToOwnRepo": false | ||
} | ||
|
||
} |
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,20 @@ | ||
import { useSession } from "next-auth/react"; | ||
import { UserRole } from "../../types"; | ||
import permissions from "../config/permissions.json"; | ||
|
||
type Permissions = { | ||
accessReviews: boolean; | ||
accessUsers: boolean; | ||
resetReviews: boolean; | ||
accessTransactions: boolean; | ||
accessAdminNav: boolean; | ||
submitToOwnRepo: boolean; | ||
}; | ||
|
||
export const useHasPermission = (permission: keyof Permissions) => { | ||
const { data: userSession } = useSession(); | ||
const userRole = userSession?.user?.permissions as UserRole; | ||
const userPermissions = permissions[userRole]; | ||
|
||
return !!userPermissions?.[permission]; | ||
}; |
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.