Skip to content
Open
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
19 changes: 19 additions & 0 deletions source/assets/js/modules/profile/controllers/logout.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* @ngdoc controller
* @name logoutController
* @description
* Handles verso logout routine
*/
angular.module('locApp.modules.profile.controllers')
.controller('logoutController', function($scope, $state, Server) {

Server.post('/verso/api/Users/logout', {})
.then(function(response) {
// $state.go('profile.list', {}, {reload: true});
document.location = '/profile-edit/';
})
.catch(function(e) {
alert('There was a problem signing out!');
document.location = '/profile-edit';
});
});
6 changes: 6 additions & 0 deletions source/assets/js/modules/profile/profile.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ angular.module('locApp.modules.profile', [
templateUrl: 'html/ontologiesForm.html',
controller: 'ontologiesController'
})
.state('profile.logout', {
parent: 'profile',
url: '/logout',
templateUrl: 'html/profileList.html',
controller: 'logoutController'
})
.state('profile.edit', {
parent: 'profile',
url: '/{id}',
Expand Down
22 changes: 21 additions & 1 deletion source/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,16 @@
<img src="assets/images/bibframe-newlogo.png"/>
<span class="bold">Library of Congress&nbsp;</span>
<span class="normal">Bibframe Profile Editor</span>

</div>
<div class="collapse navbar-collapse visible-print">
<ul class="nav navbar-nav navbar-right">
<li><a id="login-logout" href="/login.html" style="padding-top: 10px; padding-bottom: 10px">Login</a></li>
</ul>
</div>

</div>

</header>
</header>
<!-- <![endif]-->

Expand Down Expand Up @@ -260,5 +267,18 @@ <h1 class="headerTag footer sss-large-min-width">
var year = new Date(Date.now()).getFullYear();
$('#copyrightTest').html("Copyright &copy; " + year + " Library of Congress");
</script>
<script>
var cooks = document.cookie;
var ll = document.getElementById('login-logout');
if (cooks.match(/access_token=|current_user=/)) {
var userEnc = cooks.replace(/.*?current_user=(.+?)(;|$).*/, "$1")
var userDec = decodeURIComponent(userEnc);
var user = JSON.parse(userDec);
ll.innerText = 'Logout ' + user.username;
ll.href = '#/profile/logout'
} else {
ll.innerText = 'Login';
}
</script>

</html>
Loading