Added Logout Function

This commit is contained in:
Sagi Dayan 2015-06-17 20:14:53 +03:00
parent f87a14b2da
commit 3465ff3465

View file

@ -1,5 +1,7 @@
angular.module('SeHub') angular.module('SeHub')
.controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$location', function($scope, $rootScope, apiService, $cookies, $location) { .controller('mainController', ['$scope', '$rootScope', 'apiService', '$cookies', '$cookieStore', '$location', '$window',
function($scope, $rootScope, apiService, $cookies, $cookieStore, $location, $window) {
var token = $cookies['com.sehub.www']; var token = $cookies['com.sehub.www'];
@ -25,8 +27,8 @@ angular.module('SeHub')
}) })
$scope.menuItems = [{ $scope.menuItems = [{
"title": "Home", "title": "Dash Board",
"icon": "fa fa-home", "icon": "fa fa-tachometer",
"style": "selected", "style": "selected",
"route": "/home" "route": "/home"
}, { }, {
@ -63,6 +65,11 @@ angular.module('SeHub')
$scope.menuClicked = function(item) { $scope.menuClicked = function(item) {
var route = "" var route = ""
if (item.title == "Log Out") {
console.info('Logging Out!');
$cookieStore.remove('com.sehub.www');
$window.location.href = 'http://se-hub.appspot.com'; // Reference to 'welcome' page
}
for (var i = $scope.menuItems.length - 1; i >= 0; i--) { for (var i = $scope.menuItems.length - 1; i >= 0; i--) {
if ($scope.menuItems[i].title === item.title) { if ($scope.menuItems[i].title === item.title) {
$scope.menuItems[i].style = "selected"; $scope.menuItems[i].style = "selected";
@ -75,4 +82,5 @@ angular.module('SeHub')
} }
}]); }
]);