fixed bugs with authentication
This commit is contained in:
parent
19c85f9845
commit
13d9bd9ece
|
@ -48,7 +48,7 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(['$rootScope'
|
|||
var authenticator, permissions, user;
|
||||
permissions = next && next.data && next.data.permissions ? next.data.permissions : null;
|
||||
|
||||
Auth.ensureHasCurrentUser(User);
|
||||
Auth.ensureHasCurrentUser();
|
||||
user = Auth.currentUser;
|
||||
|
||||
if(user){
|
||||
|
|
|
@ -5,7 +5,7 @@ angular.module('core').controller('HeaderController', ['$rootScope', '$scope', '
|
|||
|
||||
$rootScope.signupDisabled = $window.signupDisabled;
|
||||
|
||||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser();
|
||||
|
||||
$scope.authentication = $rootScope.authentication = Auth;
|
||||
|
||||
|
@ -23,7 +23,7 @@ angular.module('core').controller('HeaderController', ['$rootScope', '$scope', '
|
|||
var promise = User.logout();
|
||||
promise.then(function() {
|
||||
Auth.logout();
|
||||
Auth.ensureHasCurrentUser(User);
|
||||
Auth.ensureHasCurrentUser();
|
||||
$scope.user = $rootScope.user = null;
|
||||
$state.go('listForms');
|
||||
|
||||
|
|
|
@ -126,6 +126,7 @@ div.form-fields {
|
|||
border: 1px solid #000;
|
||||
border: 1px solid rgba(0,0,0,.2);
|
||||
margin-right: 7px;
|
||||
margin-top: 1px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
|
|
@ -15,7 +15,7 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
|
|||
User.login($scope.credentials).then(
|
||||
function(response) {
|
||||
Auth.login(response);
|
||||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
$scope.user = $rootScope.user = Auth.ensureHasCurrentUser();
|
||||
|
||||
if(statesToIgnore.indexOf($state.previous.state.name) === -1) {
|
||||
$state.go($state.previous.state.name, $state.previous.params);
|
||||
|
@ -24,7 +24,7 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$loca
|
|||
}
|
||||
},
|
||||
function(error) {
|
||||
$rootScope.user = Auth.ensureHasCurrentUser(User);
|
||||
$rootScope.user = Auth.ensureHasCurrentUser();
|
||||
$scope.user = $rootScope.user;
|
||||
|
||||
$scope.error = error;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('users').factory('Auth', ['$window',
|
||||
function($window) {
|
||||
angular.module('users').factory('Auth', ['$window', 'User',
|
||||
function($window, User) {
|
||||
|
||||
var userState = {
|
||||
isLoggedIn: false
|
||||
|
@ -16,7 +16,7 @@ angular.module('users').factory('Auth', ['$window',
|
|||
// Note: we can't make the User a dependency of Auth
|
||||
// because that would create a circular dependency
|
||||
// Auth <- $http <- $resource <- LoopBackResource <- User <- Auth
|
||||
ensureHasCurrentUser: function(User) {
|
||||
ensureHasCurrentUser: function() {
|
||||
if (service._currentUser && service._currentUser.username) {
|
||||
return service._currentUser;
|
||||
} else if ($window.user){
|
||||
|
|
Loading…
Reference in New Issue