Skip to content
Snippets Groups Projects
Commit fcabc866 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Basic permission checking when accessing routes

parent 90ba5f83
No related branches found
No related tags found
2 merge requests!1123Resolve "Finalise Vuetify app as SPA",!1066Translations update from Weblate
Pipeline #105489 failed
......@@ -162,7 +162,25 @@
</message-box>
</div>
<router-view />
<router-view
v-if="
permissionResults &&
($route.meta.permission
? permissionResults.find(
(p) => p.name === $route.meta.permission
).result
: true)
"
/>
<message-box
type="error"
v-else-if="
permissionResults.find((p) => p.name === $route.meta.permission)
.result === false
"
>
{{ $t("base.no_permission") }}
</message-box>
</v-container>
</v-main>
......@@ -266,8 +284,8 @@ export default {
systemProperties: null,
messages: null,
footerMenu: null,
menuPermissionResults: null,
menuPermissionNames: [],
permissionResults: null,
permissionNames: [],
sideNavMenu: null,
accountMenu: null,
};
......@@ -286,7 +304,7 @@ export default {
}
}
this.$data.menuPermissionNames = permArray;
this.$data.permissionNames = permArray;
},
buildMenu(routes, menuKey, permissionResults) {
let menu = {};
......@@ -363,11 +381,11 @@ export default {
},
update: (data) => data.customMenuByName,
},
menuPermissionResults: {
permissionResults: {
query: gqlGlobalPermissions,
variables() {
return {
permissions: this.$data.menuPermissionNames,
permissions: this.$data.permissionNames,
};
},
update: (data) => data.globalPermissionsByName,
......@@ -389,7 +407,7 @@ export default {
whoAmI: function (person) {
this.$vuetify.theme.dark = person.preferences.themeDesignMode === "dark";
},
menuPermissionResults: {
permissionResults: {
handler(newResults) {
this.$data.accountMenu = this.buildMenu(
this.$router.getRoutes(),
......
......@@ -124,7 +124,8 @@
"imprint": "Imprint",
"person_is_dummy": "Your administrator account is not linked to any person. Therefore, a dummy person has been linked to your account.",
"privacy_policy": "Privacy Policy",
"user_not_linked_to_person": "Your user account is not linked to a person. This means you cannot access any school-related information. Please contact the managers of AlekSIS at your school."
"user_not_linked_to_person": "Your user account is not linked to a person. This means you cannot access any school-related information. Please contact the managers of AlekSIS at your school.",
"no_permission": "You have no permission to view this page. Please login with an other account."
},
"celery_progress": {
"error_message": "The operation couldn't be finished successfully.",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment