Skip to content

Commit

Permalink
Merge pull request #33 from Connected-Places/SUTTON-sc-2809-update-us…
Browse files Browse the repository at this point in the history
…er-permissions-admin

Simplified auth permission checks for super admin
  • Loading branch information
appsol authored Sep 21, 2023
2 parents 3965869 + ab60370 commit 95eb776
Showing 1 changed file with 11 additions and 92 deletions.
103 changes: 11 additions & 92 deletions src/classes/Auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,29 +296,8 @@ class Auth {
* @returns {boolean}
*/
canView(type) {
if (type === "admin") {
return this.isSuperAdmin;
}
if (type === "audits") {
return this.isSuperAdmin;
}
if (type === "notifications") {
return this.isSuperAdmin;
}
if (type === "feedback") {
return this.isSuperAdmin;
}
if (type === "taxonomies") {
return this.isSuperAdmin;
}
if (type === "collections") {
return this.isSuperAdmin;
}
if (type === "search engine") {
return this.isSuperAdmin;
}
if (type === "cms") {
return this.isSuperAdmin;
if (this.isSuperAdmin) {
return true;
}
if (type === "events") {
return this.isOrganisationAdmin();
Expand All @@ -338,12 +317,6 @@ class Auth {
if (type === "pages") {
return this.isContentAdmin;
}
if (type === "reports") {
return this.isSuperAdmin;
}
if (type === "update requests") {
return this.isSuperAdmin;
}
if (type === "users") {
return (
!this.isOnlyContentAdmin &&
Expand All @@ -359,14 +332,8 @@ class Auth {
* @returns {boolean}
*/
canAdd(type) {
if (type === "admin") {
return this.isSuperAdmin;
}
if (type === "taxonomies") {
return this.isSuperAdmin;
}
if (type === "collections") {
return this.isSuperAdmin;
if (this.isSuperAdmin) {
return true;
}
if (type === "event") {
return this.isOrganisationAdmin();
Expand All @@ -383,9 +350,6 @@ class Auth {
if (type === "page") {
return this.isContentAdmin;
}
if (type === "report") {
return this.isSuperAdmin;
}
if (type === "user") {
return (
!this.isOnlyContentAdmin &&
Expand All @@ -402,20 +366,8 @@ class Auth {
* @returns {boolean}
*/
canEdit(type, model = null) {
if (type === "admin") {
return this.isSuperAdmin;
}
if (type === "taxonomies") {
return this.isSuperAdmin;
}
if (type === "collections") {
return this.isSuperAdmin;
}
if (type === "search engine") {
return this.isSuperAdmin;
}
if (type === "cms") {
return this.isSuperAdmin;
if (this.isSuperAdmin) {
return true;
}
if (type === "event") {
return this.isOrganisationAdmin(model);
Expand All @@ -435,12 +387,6 @@ class Auth {
if (type === "referral") {
return this.isServiceWorker() && !this.isOnlyGlobalAdmin;
}
if (type === "report") {
return this.isSuperAdmin;
}
if (type === "update request") {
return this.isSuperAdmin;
}
if (type === "user") {
return (
!this.isOnlyContentAdmin &&
Expand All @@ -456,12 +402,9 @@ class Auth {
* @param {string} type
* @returns {boolean}
*/
canImport(type) {
if (type === "services") {
return this.isSuperAdmin;
}
if (type === "organisations") {
return this.isSuperAdmin;
canImport() {
if (this.isSuperAdmin) {
return true;
}
return false;
}
Expand All @@ -472,36 +415,12 @@ class Auth {
* @returns {boolean}
*/
canDelete(type) {
if (type === "admin") {
return this.isSuperAdmin;
}
if (type === "taxonomies") {
return this.isSuperAdmin;
}
if (type === "collections") {
return this.isSuperAdmin;
}
if (type === "event") {
return this.isSuperAdmin;
}
if (type === "service") {
return this.isSuperAdmin;
}
if (type === "organisation") {
return this.isSuperAdmin;
}
if (type === "location") {
return this.isSuperAdmin;
if (this.isSuperAdmin) {
return true;
}
if (type === "page") {
return this.isContentAdmin;
}
if (type === "referral") {
return this.isSuperAdmin;
}
if (type === "update request") {
return this.isSuperAdmin;
}
if (type === "user") {
return (
!this.isOnlyContentAdmin &&
Expand Down

0 comments on commit 95eb776

Please sign in to comment.