1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

feat(init-admin): allow to specify a username for the initial admin account (#1160)

This commit is contained in:
Anthony Lapenna 2017-08-28 20:59:13 +02:00 committed by GitHub
parent 13b2fcffd2
commit e65d132b3d
12 changed files with 385 additions and 276 deletions

View file

@ -0,0 +1,33 @@
angular.module('initAdmin', [])
.controller('InitAdminController', ['$scope', '$state', '$sanitize', 'Notifications', 'Authentication', 'StateManager', 'UserService',
function ($scope, $state, $sanitize, Notifications, Authentication, StateManager, UserService) {
$scope.logo = StateManager.getState().application.logo;
$scope.formValues = {
Username: 'admin',
Password: '',
ConfirmPassword: ''
};
$scope.createAdminUser = function() {
$('#createResourceSpinner').show();
var username = $sanitize($scope.formValues.Username);
var password = $sanitize($scope.formValues.Password);
UserService.initAdministrator(username, password)
.then(function success() {
return Authentication.login(username, password);
})
.then(function success() {
$state.go('init.endpoint');
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to create administrator user');
})
.finally(function final() {
$('#createResourceSpinner').hide();
});
};
}]);