diff --git a/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs b/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs index 2d3275320e..13c9976ab8 100644 --- a/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs +++ b/src/VirtoCommerce.Platform.Web/Controllers/Api/SecurityController.cs @@ -159,9 +159,15 @@ public async Task Logout() /// [HttpGet] [Authorize] + [AllowAnonymous] [Route("currentuser")] public async Task> GetCurrentUser() { + if (User.Identity?.IsAuthenticated != true) + { + return Ok(new { }); + } + var user = await UserManager.FindByNameAsync(CurrentUserName); if (user == null) { 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 80b3e74919..30f8c6dd21 100644 --- a/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/security.js +++ b/src/VirtoCommerce.Platform.Web/wwwroot/js/app/security/security.js @@ -52,10 +52,10 @@ angular.module('platformWebApp') $scope.loginProgress = true; // Try to login authService.login($scope.user.email, $scope.user.password, $scope.user.remember).then( - function (loggedIn) { - if (!loggedIn) { - $scope.loginProgress = false; - $scope.authError = 'invalidCredentials'; + function (result) { + $scope.loginProgress = false; + if (!result || !result.succeeded) { + $scope.authError = 'The login or password is incorrect.'; } }, function (x) { @@ -72,7 +72,7 @@ angular.module('platformWebApp') }); }; - $scope.togglePassword = function() { + $scope.togglePassword = function () { $scope.showPassword = !$scope.showPassword; } });