From 87a5c12b5469bbf0a28ce95d7949c1d85514de2f Mon Sep 17 00:00:00 2001 From: axolotle Date: Fri, 16 Apr 2021 22:35:55 +0200 Subject: [PATCH] ask confirmation to grant SSH/SFTP permissions to a group --- app/src/i18n/locales/en.json | 3 ++- app/src/views/group/GroupList.vue | 8 +++++++- app/src/views/tool/ToolFirewall.vue | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/i18n/locales/en.json b/app/src/i18n/locales/en.json index 0d9ba79b..92fd1495 100644 --- a/app/src/i18n/locales/en.json +++ b/app/src/i18n/locales/en.json @@ -91,8 +91,9 @@ "confirm_app_default": "Are you sure you want to make this app default?", "confirm_change_maindomain": "Are you sure you want to change the main domain?", "confirm_delete": "Are you sure you want to delete {name}?", - "confirm_firewall_allow": "Are you sure you want to open port {port} (protocol: {protocol}, connection: {connection})", + "confirm_firewall_allow": "dAre you sure you want to open port {port} (protocol: {protocol}, connection: {connection})", "confirm_firewall_disallow": "Are you sure you want to close port {port} (protocol: {protocol}, connection: {connection})", + "confirm_group_add_access_permission": "Are you sure you want to grant a {perm} access to your server to {name}'?", "confirm_install_custom_app": "WARNING! Installing 3rd party applications may compromise the integrity and security of your system. You should probably NOT install it unless you know what you are doing. Are you willing to take that risk?", "confirm_install_domain_root": "Are you sure you want to install this application on '/'? You will not be able to install any other app on {domain}", "confirm_app_install": "Are you sure you want to install this application?", diff --git a/app/src/views/group/GroupList.vue b/app/src/views/group/GroupList.vue index ba32b8bb..32315add 100644 --- a/app/src/views/group/GroupList.vue +++ b/app/src/views/group/GroupList.vue @@ -199,8 +199,14 @@ export default { }) }, - onPermissionChanged ({ option, groupName, action, applyMethod }) { + async onPermissionChanged ({ option, groupName, action, applyMethod }) { const permId = this.permissions.find(perm => perm.label === option).id + if (action === 'add' && ['sftp.main', 'ssh.main'].includes(permId)) { + const confirmed = await this.$askConfirmation( + this.$i18n.t('confirm_group_add_access_permission', { name: groupName, perm: option }) + ) + if (!confirmed) return + } api.put( // FIXME hacky way to update the store { uri: `users/permissions/${permId}/${action}/${groupName}`, storeKey: 'permissions', groupName, action, permId }, diff --git a/app/src/views/tool/ToolFirewall.vue b/app/src/views/tool/ToolFirewall.vue index cd0592a2..6fd45ecb 100644 --- a/app/src/views/tool/ToolFirewall.vue +++ b/app/src/views/tool/ToolFirewall.vue @@ -185,6 +185,7 @@ export default { } const actionTrad = this.$i18n.t({ allow: 'open', disallow: 'close' }[action]) + console.log(action, actionTrad) return api.put( `firewall/${protocol}/${action}/${port}?${connection}_only`, {},