diff --git a/bootstrap-ui/src/main/webapp/app/application.js b/bootstrap-ui/src/main/webapp/app/application.js index 501e57081..6b94a3e89 100644 --- a/bootstrap-ui/src/main/webapp/app/application.js +++ b/bootstrap-ui/src/main/webapp/app/application.js @@ -14,7 +14,7 @@ angular.module('smlBootstrap', ['smlBootstrap.services', 'smlBootstrap.filters', when("/error", {controller: 'EntriesController', templateUrl: "partials/errorpages/error500.html"}). when("/recover-lost-password", {controller: 'PasswordRecoveryController', templateUrl: "partials/recover-lost-password.html"}). when("/password-reset", {controller: "PasswordRecoveryController", templateUrl: "partials/password-reset.html"}). - when("/profile", {controller: "ProfileController", templateUrl: "partials/profile.html"}). + when("/profile", {controller: "ProfileController", templateUrl: "partials/secured/profile.html"}). otherwise({redirectTo: '/error404'}); }) @@ -65,6 +65,16 @@ angular.module('smlBootstrap', ['smlBootstrap.services', 'smlBootstrap.filters', showInfoMessage(message); } }); + }) + + .run(function ($rootScope, UserSessionService, $location) { + $rootScope.$on("$routeChangeStart", function (event, next, current) { + if (!UserSessionService.isLogged() && next.templateUrl.indexOf("/secured/") > -1) { + $location.path("/login"); + } else if (UserSessionService.isLogged() && next.templateUrl === "partials/login.html") { + $location.path("/"); + } + }); }); diff --git a/bootstrap-ui/src/main/webapp/app/controllers.js b/bootstrap-ui/src/main/webapp/app/controllers.js index 816ec234a..0ea03c061 100644 --- a/bootstrap-ui/src/main/webapp/app/controllers.js +++ b/bootstrap-ui/src/main/webapp/app/controllers.js @@ -23,7 +23,7 @@ controllers.controller('UptimeController', function UptimeController($scope, $ti }); -controllers.controller('EntriesController', function EntriesController($scope, $timeout, $window, EntriesService, UserSessionService) { +controllers.controller('EntriesController', function EntriesController($scope, $timeout, $window, EntriesService, UserSessionService, $location) { var self = this; @@ -108,8 +108,10 @@ controllers.controller('EntriesController', function EntriesController($scope, $ }; $scope.logout = function () { - UserSessionService.logout(); - showInfoMessage("Logged out successfully"); + UserSessionService.logout(function(data) { + showInfoMessage("Logged out successfully"); + $location.path("/"); + }); }; }); diff --git a/bootstrap-ui/src/main/webapp/partials/profile.html b/bootstrap-ui/src/main/webapp/partials/secured/profile.html similarity index 100% rename from bootstrap-ui/src/main/webapp/partials/profile.html rename to bootstrap-ui/src/main/webapp/partials/secured/profile.html