Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated logout button into the UI #1170

Merged
merged 1 commit into from
Aug 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Integrated logout button into the UI
  • Loading branch information
Thomas Boerger committed Aug 27, 2015
commit 2577b6cda26d0938da9ee932b4c550f7614f3df2
21 changes: 17 additions & 4 deletions cmd/drone-server/static/scripts/controllers/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
$scope.user = payload.data;
});

$scope.number = $stateParams.number || undefined;
$scope.owner = $stateParams.owner || undefined;
$scope.name = $stateParams.name || undefined;
$scope.full_name = $scope.owner + '/' + $scope.name;
$scope.number = $stateParams.number || undefined;
$scope.owner = $stateParams.owner || undefined;
$scope.name = $stateParams.name || undefined;
$scope.full_name = $scope.owner + '/' + $scope.name;
}

function UserLoginCtrl($scope, $window) {
Expand All @@ -18,6 +18,18 @@
$scope.error = $window.location.hash.substr(7);
}

function UserLogoutCtrl($scope, $window, $state) {
// Remove login information from the local
// storage and redirect to login page
if (localStorage.hasOwnProperty("access_token")) {
localStorage.removeItem("access_token");
}

$state.go("login", {}, {
location: "replace"
});
}

/**
* UserCtrl is responsible for managing user settings.
*/
Expand Down Expand Up @@ -115,6 +127,7 @@
.module('drone')
.controller('UserHeaderCtrl', UserHeaderCtrl)
.controller('UserLoginCtrl', UserLoginCtrl)
.controller('UserLogoutCtrl', UserLogoutCtrl)
.controller('UserCtrl', UserCtrl)
.controller('UsersCtrl', UsersCtrl);
})();
11 changes: 11 additions & 0 deletions cmd/drone-server/static/scripts/drone.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@
},
title: 'Login'
})
.state('logout', {
url: '/logout',
views: {
'layout': {
templateUrl: '/static/scripts/views/login.html',
controller: 'UserLogoutCtrl',
resolve: resolveUser
}
},
title: 'Logout'
})
.state('app.profile', {
url: '/profile',
views: {
Expand Down
3 changes: 2 additions & 1 deletion cmd/drone-server/static/scripts/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ul>
<li><a href="/profile">Profile</a></li>
<li><a href="/users">Users</a></li>
<li><a href="/logout">Logout</a></li>
</ul>
</div>
</li>
Expand Down Expand Up @@ -71,4 +72,4 @@
.dropdown li > a:hover {
background:#F5F7F9;
}
</style>
</style>