summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/api/roles.js15
-rw-r--r--server/api/users.js5
-rw-r--r--webapp/src/components/PermissionModuleEdit.vue2
-rw-r--r--webapp/src/components/PermissionModuleGrantRevoke.vue4
4 files changed, 11 insertions, 15 deletions
diff --git a/server/api/roles.js b/server/api/roles.js
index 3b86f50..8d5cf4e 100644
--- a/server/api/roles.js
+++ b/server/api/roles.js
@@ -11,9 +11,8 @@ var router = decorateApp(express.Router())
* @return: Returns the information about a role and it's permissions and groups.
*/
router.getAsync('/:id', async (req, res) => {
- if (!await req.user.hasPermission('permissions.*')) {
- res.status(403).end()
- }
+ if (!await req.user.hasPermission('permissions.*')) return res.status(403).end()
+
var role = await db.role.findOne({ where: { id: req.params.id }, include: ['permissions', 'groups'] })
if (role) res.send(role)
else res.status(404).end()
@@ -23,9 +22,8 @@ router.getAsync('/:id', async (req, res) => {
* @return: Returns a list of all roles in the database.
*/
router.getAsync('', async (req, res) => {
- if (!await req.user.hasPermission('permissions.*')) {
- res.status(403).end()
- }
+ if (!await req.user.hasPermission('permissions.*')) return res.status(403).end()
+
var roles = await db.role.findAll({ attributes: ['id', 'name', 'descr'] })
res.status(200).send(roles)
})
@@ -42,9 +40,8 @@ router.getAsync('', async (req, res) => {
*
*/
router.postAsync(['', '/:id'], async (req, res) => {
- if (!await req.user.hasPermission('permissions.editrole')) {
- res.status(403).end()
- }
+ if (!await req.user.hasPermission('permissions.editrole')) return res.status(403).end()
+
// ?delete Delete the roles
if (req.query.delete !== undefined && req.query.delete !== 'false') {
await db.role.destroy({ where: { id: req.body.ids } })
diff --git a/server/api/users.js b/server/api/users.js
index a754155..a297033 100644
--- a/server/api/users.js
+++ b/server/api/users.js
@@ -44,9 +44,8 @@ router.getAsync('/:id', async (req, res) => {
// Post request for adding roles to users.
router.postAsync('/:id/roles', async (req, res) => {
- if (!await req.user.hasPermission('permissions.grantrevoke')) {
- res.status(403).end()
- }
+ if (!await req.user.hasPermission('permissions.grantrevoke')) return res.status(403).end()
+
const id = req.params.id === 'current' ? req.user.id : req.params.id
const user = await db.user.findOne({ where: { id } })
if (user) {
diff --git a/webapp/src/components/PermissionModuleEdit.vue b/webapp/src/components/PermissionModuleEdit.vue
index 70c61f4..c026f54 100644
--- a/webapp/src/components/PermissionModuleEdit.vue
+++ b/webapp/src/components/PermissionModuleEdit.vue
@@ -272,7 +272,7 @@ export default {
groups: filteredGroups,
blacklist: filteredBlacklist
}).then(response => {
- this.$snackbar({ color: 'success', text: this.$t('roleSavedSuccess'), timeout: 15000 })
+ this.$snackbar({ color: 'success', text: this.$t('roleSavedSuccess') })
this.$store.dispatch('permissions/loadRoleData')
this.$store.commit('permissions/setEdit', false)
}).catch(error => {
diff --git a/webapp/src/components/PermissionModuleGrantRevoke.vue b/webapp/src/components/PermissionModuleGrantRevoke.vue
index 81afece..a137ea1 100644
--- a/webapp/src/components/PermissionModuleGrantRevoke.vue
+++ b/webapp/src/components/PermissionModuleGrantRevoke.vue
@@ -147,9 +147,9 @@ export default {
await this.$http.post('/api/users/' + this.selectedUsers[i].id + '/roles' + (this.grant ? '' : '/?delete'), { ids: roleIds })
}
if (this.grant) {
- this.$snackbar({ color: 'success', text: this.$t('roleGrantedSuccess'), timeout: 15000 })
+ this.$snackbar({ color: 'success', text: this.$t('roleGrantedSuccess') })
} else {
- this.$snackbar({ color: 'success', text: this.$t('roleRevokedSuccess'), timeout: 15000 })
+ this.$snackbar({ color: 'success', text: this.$t('roleRevokedSuccess') })
}
this.$store.dispatch('permissions/loadUserData')
this.$store.commit('permissions/setGrantRevoke', false)