In the spirit of DRY: centralized IsAdmin() check in an extension method

Made sure that non-admins can't trigger the enable/disable URL tracker endpoint
Renamed "admin" in GetEnableState to "isUserAdmin" for clarity
This commit is contained in:
Sebastiaan Janssen
2016-09-04 11:44:16 +02:00
parent fee217e8d7
commit 8d291efedd
6 changed files with 35 additions and 13 deletions

View File

@@ -15,7 +15,7 @@
searchTerm: "",
loading: false,
urlTrackerDisabled: false,
admin: false
userIsAdmin: false
};
vm.pagination = {
@@ -43,7 +43,7 @@
vm.dashboard.loading = true;
return redirectUrlsResource.getEnableState().then(function (response) {
vm.dashboard.urlTrackerDisabled = response.enabled !== true;
vm.dashboard.admin = response.admin;
vm.dashboard.userIsAdmin = response.userIsAdmin;
vm.dashboard.loading = false;
});
}

View File

@@ -6,7 +6,7 @@
<umb-editor-sub-header-content-right>
<umb-editor-sub-header-section ng-if="vm.dashboard.admin === true">
<umb-editor-sub-header-section ng-if="vm.dashboard.userIsAdmin === true">
<button
ng-if="vm.dashboard.urlTrackerDisabled === false"