fix(authentication): fix an issue with the --no-auth flag (#2090)

pull/2103/head
Anthony Lapenna 2018-07-28 16:38:26 +02:00 committed by GitHub
parent 2e0d1f289c
commit 024739f9f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 11 deletions

View File

@ -15,7 +15,7 @@ function ($scope, $state, $transition$, $sanitize, Authentication, UserService,
function unauthenticatedFlow() {
EndpointService.endpoints()
.then(function success(data) {
.then(function success(endpoints) {
if (endpoints.length === 0) {
$state.go('portainer.init.endpoint');
} else {

View File

@ -16,17 +16,20 @@ function ($q, $scope, StateManager, Notifications, Authentication, UserService)
$scope.uiVersion = StateManager.getState().application.version;
$scope.logo = StateManager.getState().application.logo;
var userDetails = Authentication.getUserDetails();
var isAdmin = userDetails.role === 1;
$scope.isAdmin = isAdmin;
var authenticationEnabled = $scope.applicationState.application.authentication;
if (authenticationEnabled) {
var userDetails = Authentication.getUserDetails();
var isAdmin = userDetails.role === 1;
$scope.isAdmin = isAdmin;
$q.when(!isAdmin ? UserService.userMemberships(userDetails.ID) : [])
.then(function success(data) {
checkPermissions(data);
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve user memberships');
});
$q.when(!isAdmin ? UserService.userMemberships(userDetails.ID) : [])
.then(function success(data) {
checkPermissions(data);
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve user memberships');
});
}
}
initView();