@@ -1464,24 +1464,17 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
|
||||
});
|
||||
};
|
||||
|
||||
Client.prototype.createAdmin = function (username, password, email, displayName, callback) {
|
||||
Client.prototype.createAdmin = function (data, callback) {
|
||||
var that = this;
|
||||
|
||||
var data = {
|
||||
username: username,
|
||||
password: password,
|
||||
email: email,
|
||||
displayName: displayName
|
||||
};
|
||||
|
||||
post('/api/v1/cloudron/activate', data, null, function (error, data, status) {
|
||||
post('/api/v1/cloudron/activate', data, null, function (error, result, status) {
|
||||
if (error) return callback(error);
|
||||
if (status !== 201) return callback(new ClientError(status, data));
|
||||
if (status !== 201) return callback(new ClientError(status, result));
|
||||
|
||||
that.setToken(data.token);
|
||||
that.setUserInfo({ username: username, email: email, admin: true, twoFactorAuthenticationEnabled: false, source: '', avatarUrl: null });
|
||||
that.setToken(result.token);
|
||||
that.setUserInfo({ username: data.username, email: data.email, admin: true, twoFactorAuthenticationEnabled: false, source: '', avatarUrl: null });
|
||||
|
||||
callback(null, data.activated);
|
||||
callback(null, result.activated);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
if (!status.activated) {
|
||||
console.log('Not activated yet, redirecting', status);
|
||||
if (status.restore.active || status.restore.errorMessage) { // show the error message in restore page
|
||||
window.location.href = '/restore.html';
|
||||
window.location.href = '/restore.html' + window.location.search;
|
||||
} else {
|
||||
window.location.href = status.adminFqdn ? '/setup.html' : '/setupdns.html';
|
||||
window.location.href = (status.adminFqdn ? '/setup.html' : '/setupdns.html') + window.location.search;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
// support local development with localhost check
|
||||
if (window.location.hostname !== status.adminFqdn && window.location.hostname !== 'localhost') {
|
||||
// user is accessing by IP or by the old admin location (pre-migration)
|
||||
window.location.href = '/setupdns.html';
|
||||
window.location.href = '/setupdns.html' + window.location.search;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
|
||||
$scope.advancedVisible = false;
|
||||
$scope.password = '';
|
||||
$scope.encrypted = false; // only used if a backup config contains that flag
|
||||
$scope.setupToken = '';
|
||||
|
||||
$scope.sysinfo = {
|
||||
provider: 'generic',
|
||||
@@ -159,7 +160,8 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
|
||||
|
||||
var backupConfig = {
|
||||
provider: $scope.provider,
|
||||
format: $scope.format
|
||||
format: $scope.format,
|
||||
setupToken: $scope.setupToken
|
||||
};
|
||||
if ($scope.password) backupConfig.password = $scope.password;
|
||||
|
||||
@@ -374,6 +376,7 @@ app.controller('RestoreController', ['$scope', 'Client', function ($scope, Clien
|
||||
|
||||
$scope.status = status;
|
||||
$scope.instanceId = search.instanceId;
|
||||
$scope.setupToken = search.setupToken;
|
||||
$scope.initialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ app.controller('SetupController', ['$scope', 'Client', function ($scope, Client)
|
||||
$scope.initialized = false;
|
||||
$scope.apiServerOrigin = '';
|
||||
$scope.webServerOrigin = '';
|
||||
$scope.setupToken = '';
|
||||
|
||||
$scope.owner = {
|
||||
error: null,
|
||||
@@ -29,7 +30,15 @@ app.controller('SetupController', ['$scope', 'Client', function ($scope, Client)
|
||||
$scope.owner.busy = true;
|
||||
$scope.owner.error = null;
|
||||
|
||||
Client.createAdmin($scope.owner.username, $scope.owner.password, $scope.owner.email, $scope.owner.displayName, function (error) {
|
||||
var data = {
|
||||
username: $scope.owner.username,
|
||||
password: $scope.owner.password,
|
||||
email: $scope.owner.email,
|
||||
displayName: $scope.owner.displayName,
|
||||
setupToken: $scope.setupToken
|
||||
};
|
||||
|
||||
Client.createAdmin(data, function (error) {
|
||||
if (error && error.statusCode === 400) {
|
||||
$scope.owner.busy = false;
|
||||
$scope.owner.error = { username: error.message };
|
||||
@@ -92,6 +101,7 @@ app.controller('SetupController', ['$scope', 'Client', function ($scope, Client)
|
||||
$scope.apiServerOrigin = status.apiServerOrigin;
|
||||
$scope.webServerOrigin = status.webServerOrigin;
|
||||
|
||||
$scope.setupToken = search.setupToken;
|
||||
$scope.initialized = true;
|
||||
|
||||
// Ensure we have a good autofocus
|
||||
|
||||
@@ -24,6 +24,8 @@ app.controller('SetupDNSController', ['$scope', '$http', '$timeout', 'Client', f
|
||||
$scope.advancedVisible = false;
|
||||
$scope.webServerOrigin = '';
|
||||
$scope.clipboardDone = false;
|
||||
$scope.search = window.location.search;
|
||||
$scope.setupToken = '';
|
||||
|
||||
$scope.tlsProvider = [
|
||||
{ name: 'Let\'s Encrypt Prod', value: 'letsencrypt-prod' },
|
||||
@@ -220,14 +222,19 @@ app.controller('SetupDNSController', ['$scope', '$http', '$timeout', 'Client', f
|
||||
tlsConfig: tlsConfig
|
||||
},
|
||||
sysinfoConfig: sysinfoConfig,
|
||||
providerToken: $scope.instanceId
|
||||
providerToken: $scope.instanceId,
|
||||
setupToken: $scope.setupToken
|
||||
};
|
||||
|
||||
Client.setup(data, function (error) {
|
||||
if (error) {
|
||||
$scope.dnsCredentials.busy = false;
|
||||
if (error.statusCode === 422) {
|
||||
$scope.error.ami = error.message;
|
||||
if (provider === 'ami') {
|
||||
$scope.error.ami = error.message;
|
||||
} else {
|
||||
$scope.error.setup = error.message;
|
||||
}
|
||||
} else {
|
||||
$scope.error.dnsCredentials = error.message;
|
||||
}
|
||||
@@ -248,7 +255,7 @@ app.controller('SetupDNSController', ['$scope', '$http', '$timeout', 'Client', f
|
||||
$scope.state = 'initialized';
|
||||
$scope.dnsCredentials.busy = false;
|
||||
} else { // proceed to activation
|
||||
window.location.href = 'https://' + status.adminFqdn + '/setup.html';
|
||||
window.location.href = 'https://' + status.adminFqdn + '/setup.html' + (window.location.search);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -283,6 +290,7 @@ app.controller('SetupDNSController', ['$scope', '$http', '$timeout', 'Client', f
|
||||
}
|
||||
|
||||
$scope.instanceId = search.instanceId;
|
||||
$scope.setupToken = search.setupToken;
|
||||
$scope.provider = status.provider;
|
||||
$scope.webServerOrigin = status.webServerOrigin;
|
||||
$scope.state = 'initialized';
|
||||
|
||||
Reference in New Issue
Block a user