Handle signout properly
RefStack UI should properly handle user signout. How to check: Open two RefStack in two browser tabs and signin in both. Then signout in first tab. Then try to open 'Profile' or 'My Results' in second tab. If everything is ok you will be redirected to RefStack home tab. Change-Id: Ifc14ba953b269ce8940f82e61d7f3634682fe0da
This commit is contained in:
parent
4b29aec3b6
commit
8f8bf6dce3
@ -53,8 +53,8 @@ refstackApp.config([
|
|||||||
* Injections in $rootscope
|
* Injections in $rootscope
|
||||||
*/
|
*/
|
||||||
|
|
||||||
refstackApp.run(['$http', '$rootScope', '$window', 'refstackApiUrl',
|
refstackApp.run(['$http', '$rootScope', '$window', '$state', 'refstackApiUrl',
|
||||||
function($http, $rootScope, $window, refstackApiUrl) {
|
function($http, $rootScope, $window, $state, refstackApiUrl) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,15 +82,19 @@ refstackApp.run(['$http', '$rootScope', '$window', 'refstackApiUrl',
|
|||||||
* This block tries to authenticate user
|
* This block tries to authenticate user
|
||||||
*/
|
*/
|
||||||
var profile_url = refstackApiUrl + '/profile';
|
var profile_url = refstackApiUrl + '/profile';
|
||||||
$http.get(profile_url, {withCredentials: true}).
|
$rootScope.auth.doSignCheck = function () {
|
||||||
success(function(data) {
|
return $http.get(profile_url, {withCredentials: true}).
|
||||||
$rootScope.auth.currentUser = data;
|
success(function (data) {
|
||||||
$rootScope.auth.isAuthenticated = true;
|
$rootScope.auth.currentUser = data;
|
||||||
}).
|
$rootScope.auth.isAuthenticated = true;
|
||||||
error(function() {
|
}).
|
||||||
$rootScope.auth.currentUser = null;
|
error(function () {
|
||||||
$rootScope.auth.isAuthenticated = false;
|
$rootScope.auth.currentUser = null;
|
||||||
});
|
$rootScope.auth.isAuthenticated = false;
|
||||||
|
$state.go('home');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
$rootScope.auth.doSignCheck();
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<h3>User profile</h3>
|
<h3>User profile</h3>
|
||||||
|
<div cg-busy="{promise:authRequest,message:'Loading'}"></div>
|
||||||
<div>
|
<div>
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -9,27 +9,29 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="container-fluid">
|
<div ng-show="pubkeys">
|
||||||
<div class="row">
|
<div class="container-fluid">
|
||||||
<div class="col-md-4">
|
<div class="row">
|
||||||
<h4>User public keys</h4>
|
<div class="col-md-4">
|
||||||
</div>
|
<h4>User public keys</h4>
|
||||||
<div class="col-md-2 pull-right">
|
</div>
|
||||||
<button type="button" class="btn btn-default btn-sm" ng-click="openImportPubKeyModal()">
|
<div class="col-md-2 pull-right">
|
||||||
<span class="glyphicon glyphicon-plus"></span> Import public key
|
<button type="button" class="btn btn-default btn-sm" ng-click="openImportPubKeyModal()">
|
||||||
</button>
|
<span class="glyphicon glyphicon-plus"></span> Import public key
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="pubKey in pubkeys" ng-click="openShowPubKeyModal(pubKey)">
|
<tr ng-repeat="pubKey in pubkeys" ng-click="openShowPubKeyModal(pubKey)">
|
||||||
<td>{{pubKey.format}}</td>
|
<td>{{pubKey.format}}</td>
|
||||||
<td>{{pubKey.shortKey}}</td>
|
<td>{{pubKey.shortKey}}</td>
|
||||||
<td>{{pubKey.comment}}</td>
|
<td>{{pubKey.comment}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
@ -14,9 +14,9 @@ refstackApp.factory('PubKeys',
|
|||||||
|
|
||||||
refstackApp.controller('profileController',
|
refstackApp.controller('profileController',
|
||||||
[
|
[
|
||||||
'$scope', '$http', 'refstackApiUrl', '$state', 'PubKeys',
|
'$scope', '$http', 'refstackApiUrl', 'PubKeys',
|
||||||
'$modal', 'raiseAlert',
|
'$modal', 'raiseAlert',
|
||||||
function($scope, $http, refstackApiUrl, $state,
|
function($scope, $http, refstackApiUrl,
|
||||||
PubKeys, $modal, raiseAlert) {
|
PubKeys, $modal, raiseAlert) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -67,7 +67,8 @@ refstackApp.controller('profileController',
|
|||||||
$scope.showRes = function(pubKey){
|
$scope.showRes = function(pubKey){
|
||||||
raiseAlert('success', '', pubKey.pubkey);
|
raiseAlert('success', '', pubKey.pubkey);
|
||||||
};
|
};
|
||||||
$scope.updatePubKeys();
|
$scope.authRequest = $scope.auth.doSignCheck()
|
||||||
|
.then($scope.updatePubKeys);
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div cg-busy="{promise:authRequest,message:'Loading'}"></div>
|
||||||
<div cg-busy="{promise:resultsRequest,message:'Loading'}"></div>
|
<div cg-busy="{promise:resultsRequest,message:'Loading'}"></div>
|
||||||
<div ng-show="data" class="results-table">
|
<div ng-show="data" class="results-table">
|
||||||
<table ng-show="data" class="table table-striped table-hover">
|
<table ng-show="data" class="table table-striped table-hover">
|
||||||
|
@ -72,8 +72,12 @@ refstackApp.controller('resultsController',
|
|||||||
JSON.stringify(error);
|
JSON.stringify(error);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
if ($scope.isUserResults) {
|
||||||
$scope.update();
|
$scope.authRequest = $scope.auth.doSignCheck()
|
||||||
|
.then($scope.update);
|
||||||
|
} else {
|
||||||
|
$scope.update();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called when the date filter calendar is opened. It
|
* This is called when the date filter calendar is opened. It
|
||||||
|
@ -2,7 +2,7 @@ describe('Auth', function () {
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var fakeApiUrl = 'http://foo.bar/v1';
|
var fakeApiUrl = 'http://foo.bar/v1';
|
||||||
var $window;
|
var $window, $rootScope, $httpBackend;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
$window = {location: { href: jasmine.createSpy()} };
|
$window = {location: { href: jasmine.createSpy()} };
|
||||||
module(function ($provide) {
|
module(function ($provide) {
|
||||||
@ -10,14 +10,13 @@ describe('Auth', function () {
|
|||||||
$provide.value('$window', $window);
|
$provide.value('$window', $window);
|
||||||
});
|
});
|
||||||
module('refstackApp');
|
module('refstackApp');
|
||||||
|
inject(function (_$httpBackend_, _$rootScope_) {
|
||||||
|
$httpBackend = _$httpBackend_;
|
||||||
|
$rootScope = _$rootScope_;
|
||||||
|
});
|
||||||
|
$httpBackend.whenGET('/components/home/home.html')
|
||||||
|
.respond('<div>mock template</div>');
|
||||||
});
|
});
|
||||||
|
|
||||||
var $rootScope, $httpBackend;
|
|
||||||
beforeEach(inject(function (_$httpBackend_, _$rootScope_) {
|
|
||||||
$httpBackend = _$httpBackend_;
|
|
||||||
$rootScope = _$rootScope_;
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('should show signin url for signed user', function () {
|
it('should show signin url for signed user', function () {
|
||||||
$httpBackend.expectGET(fakeApiUrl +
|
$httpBackend.expectGET(fakeApiUrl +
|
||||||
'/profile').respond({'openid': 'foo@bar.com',
|
'/profile').respond({'openid': 'foo@bar.com',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user