Merge pull request #1756 from emanuelschuetze/fix1750

Redirect to login dialog if user is not logged in (Fixes #1750)
This commit is contained in:
Norman Jäckel 2015-12-09 23:16:22 +01:00
commit ea6a6206a0
2 changed files with 16 additions and 8 deletions

View File

@ -91,7 +91,7 @@
</div> </div>
<!-- Login button --> <!-- Login button -->
<div ng-if="!operator.isAuthenticated()"> <div ng-if="!operator.isAuthenticated()">
<a href ng-click="openLoginForm()" class="headerlink" uib-dropdown-toggle> <a href ui-sref="login" class="headerlink" uib-dropdown-toggle>
<i class="fa fa-sign-in"></i> <i class="fa fa-sign-in"></i>
<translate>Login</translate> <translate>Login</translate>
</a> </a>

View File

@ -117,6 +117,15 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' }); return $http({ 'method': 'OPTIONS', 'url': '/rest/users/group/' });
} }
} }
})
.state('login', {
template: null,
onEnter: ['$stateParams', 'ngDialog', function($stateParams, ngDialog) {
ngDialog.open({
template: 'static/templates/core/login-form.html',
controller: 'LoginFormCtrl',
});
}]
}); });
}) })
@ -124,11 +133,16 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
'operator', 'operator',
'$rootScope', '$rootScope',
'$http', '$http',
'$state',
'Group', 'Group',
function(operator, $rootScope, $http, Group) { function(operator, $rootScope, $http, $state, Group) {
// Put the operator into the root scope // Put the operator into the root scope
$http.get('/users/whoami/').success(function(data) { $http.get('/users/whoami/').success(function(data) {
operator.setUser(data.user_id); operator.setUser(data.user_id);
if (data.user_id == null) {
// redirect to login dialog if use is not logged in
$state.go('login');
}
}); });
$rootScope.operator = operator; $rootScope.operator = operator;
// Load all Groups. They are needed later // Load all Groups. They are needed later
@ -696,12 +710,6 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
// DS.flush(); // DS.flush();
}); });
}; };
$scope.openLoginForm = function () {
ngDialog.open({
template: 'static/templates/core/login-form.html',
controller: 'LoginFormCtrl',
});
};
} }
]) ])