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:
parent
13b2fcffd2
commit
e65d132b3d
12 changed files with 385 additions and 276 deletions
33
app/components/initAdmin/initAdminController.js
Normal file
33
app/components/initAdmin/initAdminController.js
Normal 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();
|
||||
});
|
||||
};
|
||||
|
||||
}]);
|
Loading…
Add table
Add a link
Reference in a new issue