From 7f3a26e1c0ddb4257ca3099ea84b4d95f2ce0618 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Thu, 4 Jan 2018 12:40:45 +0000 Subject: [PATCH] fix: error when user have no commands; close #293 Former-commit-id: 9e1ebf686f12d76a202bf8a3b0b16f14f8eb713d [formerly bfc761cc181d6d8880fd86396e69bf5894806f6c] [formerly 774e09b49a2dff07becff48bf048b3b0bd8353ed [formerly 65d3c0fb9b52829c7006cdf6487c377f61043fef]] Former-commit-id: 8ab97c0103cde1a9bcf69c1e9af994241fb9d124 [formerly a25dc7feb0755122c7329e3a3bfa61f74418467b] Former-commit-id: 92e21139ffe04ab23406352e0a5b6131e8cad084 --- assets/src/utils/auth.js | 5 +++++ assets/src/views/settings/User.vue | 5 ++++- rice-box.go.REMOVED.git-id | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 rice-box.go.REMOVED.git-id diff --git a/assets/src/utils/auth.js b/assets/src/utils/auth.js index 4bbd03b2..290b0ed3 100644 --- a/assets/src/utils/auth.js +++ b/assets/src/utils/auth.js @@ -8,6 +8,11 @@ function parseToken (token) { document.cookie = `auth=${token}; max-age=86400; path=${path}` let res = token.split('.') let user = JSON.parse(window.atob(res[1])) + + if (!user.commands) { + user.commands = [] + } + store.commit('setJWT', token) store.commit('setUser', user) } diff --git a/assets/src/views/settings/User.vue b/assets/src/views/settings/User.vue index 6619e17b..562462cf 100644 --- a/assets/src/views/settings/User.vue +++ b/assets/src/views/settings/User.vue @@ -163,11 +163,14 @@ export default { this.lockPassword = user.lockPassword this.filesystem = user.filesystem this.username = user.username - this.commands = user.commands.join(' ') this.css = user.css this.permissions = user.permissions this.locale = user.locale + if (user.commands) { + this.commands = user.commands.join(' ') + } + for (let rule of user.rules) { if (rule.allow) { this.rules += 'allow ' diff --git a/rice-box.go.REMOVED.git-id b/rice-box.go.REMOVED.git-id deleted file mode 100644 index 8aefbb45..00000000 --- a/rice-box.go.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -88021017420cd941317b4af47937c56060e5b104 \ No newline at end of file