From 9b928abdae4041217505d0c4eed8f530f665909a Mon Sep 17 00:00:00 2001 From: Basil Kotov Date: Mon, 9 Sep 2024 11:36:34 +0100 Subject: [PATCH] VCST-1280: display message when user doesn't have permissions (#2830) Co-authored-by: artem-dudarev --- .../en.VirtoCommerce.Platform.json | 7 +++++++ .../wwwroot/css/themes/main/sass/main.sass | 1 + .../main/sass/modules/_contact-admin.sass | 16 ++++++++++++++ .../wwwroot/js/app/app.js | 4 +++- .../security/dialogs/contact-admin.tpl.html | 21 +++++++++++++++++++ .../wwwroot/js/app/security/security.js | 8 +++++++ 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/modules/_contact-admin.sass create mode 100644 src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/dialogs/contact-admin.tpl.html diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/Localizations/en.VirtoCommerce.Platform.json b/src/VirtoCommerce.Platform.Web/wwwroot/Localizations/en.VirtoCommerce.Platform.json index 3680d143c04..beebdbec619 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/Localizations/en.VirtoCommerce.Platform.json +++ b/src/VirtoCommerce.Platform.Web/wwwroot/Localizations/en.VirtoCommerce.Platform.json @@ -566,6 +566,13 @@ "login-or-email": "Please enter login or email" } }, + "access-denied": { + "title": "Access denied", + "labels": { + "message": "You don't have access to this resource. Please contact your administrator.", + "button": "Login with another credentials" + } + }, "resetpassword": { "title": "Password reset", "labels": { diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/main.sass b/src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/main.sass index fcc919c1298..cfafaf55df4 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/main.sass +++ b/src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/main.sass @@ -32,6 +32,7 @@ @import "modules/_login-form.sass" @import "modules/_forgot-password.sass" +@import "modules/_contact-admin.sass" @import "modules/_auth.sass" @import "modules/_socials.sass" @import "modules/_blade-header.sass" diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/modules/_contact-admin.sass b/src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/modules/_contact-admin.sass new file mode 100644 index 00000000000..9703f101150 --- /dev/null +++ b/src/VirtoCommerce.Platform.Web/wwwroot/css/themes/main/sass/modules/_contact-admin.sass @@ -0,0 +1,16 @@ +.contact-admin + display: flex + flex-direction: column + gap: 30px + padding-bottom: 26px + width: 100% + max-width: 375px + + &__buttons + display: flex + justify-content: space-between + + &__button + min-width: 90px + @media (min-width: 768px) + min-width: 140px diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/app.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/app.js index 7507a40c07a..d13f6e6cfe7 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/app.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/app.js @@ -50,7 +50,7 @@ angular.module('platformWebApp', AppDependencies).controller('platformWebApp.app modules.query().$promise.then(function (results) { moduleHelper.modules = results; moduleHelper.onLoaded(); - + var modulesWithErrors = _.filter(results, function (x) { return _.any(x.validationErrors) && x.isInstalled; }); if (_.any(modulesWithErrors)) { $scope.platformError = { @@ -437,6 +437,8 @@ angular.module('platformWebApp', AppDependencies).controller('platformWebApp.app } } }); + } else if (!authContext.isAdministrator && !authContext.permissions?.length) { + $state.go('contact-admin'); } else if (!currentState.name || currentState.name === 'loginDialog') { $state.go('workspace'); } diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/dialogs/contact-admin.tpl.html b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/dialogs/contact-admin.tpl.html new file mode 100644 index 00000000000..f11996489cf --- /dev/null +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/dialogs/contact-admin.tpl.html @@ -0,0 +1,21 @@ +
+
+
+ +

{{ 'platform.blades.access-denied.title' | translate }}

+
+
+
+
+ {{ 'platform.blades.access-denied.labels.message' | translate }} +
+
+ +
+
+
+
+
+
+
+
diff --git a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/security.js b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/security.js index 7f81f0c4da4..3e65f10eab1 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/security.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/security.js @@ -198,6 +198,14 @@ angular.module('platformWebApp') onClose: null }, controller: 'platformWebApp.changePasswordDialog' + }) + + .state('contact-admin', { + url: '/contact-admin', + templateUrl: '$(Platform)/Scripts/app/security/dialogs/contact-admin.tpl.html', + controller: ['$scope', 'platformWebApp.authService', function ($scope, authService) { + $scope.logout = authService.logout; + }] }); }])