add setup_token to setup and restore

part of cloudron/box#751
This commit is contained in:
Girish Ramakrishnan
2020-12-21 22:36:43 -08:00
parent de5c1ca1cf
commit 29f7b771a1
7 changed files with 37 additions and 22 deletions

View File

@@ -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';