Merge pull request #1756 from emanuelschuetze/fix1750
Redirect to login dialog if user is not logged in (Fixes #1750)
This commit is contained in:
commit
ea6a6206a0
@ -91,7 +91,7 @@
|
||||
</div>
|
||||
<!-- Login button -->
|
||||
<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>
|
||||
<translate>Login</translate>
|
||||
</a>
|
||||
|
@ -117,6 +117,15 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
||||
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',
|
||||
'$rootScope',
|
||||
'$http',
|
||||
'$state',
|
||||
'Group',
|
||||
function(operator, $rootScope, $http, Group) {
|
||||
function(operator, $rootScope, $http, $state, Group) {
|
||||
// Put the operator into the root scope
|
||||
$http.get('/users/whoami/').success(function(data) {
|
||||
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;
|
||||
// Load all Groups. They are needed later
|
||||
@ -696,12 +710,6 @@ angular.module('OpenSlidesApp.users.site', ['OpenSlidesApp.users'])
|
||||
// DS.flush();
|
||||
});
|
||||
};
|
||||
$scope.openLoginForm = function () {
|
||||
ngDialog.open({
|
||||
template: 'static/templates/core/login-form.html',
|
||||
controller: 'LoginFormCtrl',
|
||||
});
|
||||
};
|
||||
}
|
||||
])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user