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() { function unauthenticatedFlow() {
EndpointService.endpoints() EndpointService.endpoints()
.then(function success(data) { .then(function success(endpoints) {
if (endpoints.length === 0) { if (endpoints.length === 0) {
$state.go('portainer.init.endpoint'); $state.go('portainer.init.endpoint');
} else { } else {

View File

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