Move AMI instanceId verification to DNS setup

This commit is contained in:
Johannes Zellner
2017-04-03 21:27:40 +02:00
parent 4f9273819a
commit b9711d7b47
6 changed files with 36 additions and 14 deletions

View File

@@ -20,12 +20,11 @@ app.controller('SetupController', ['$scope', '$http', 'Client', function ($scope
$scope.provider = '';
$scope.apiServerOrigin = '';
$scope.setupToken = '';
$scope.instanceId = '';
$scope.activateCloudron = function () {
$scope.busy = true;
Client.createAdmin($scope.account.username, $scope.account.password, $scope.account.email, $scope.account.displayName, $scope.setupToken || $scope.instanceId, function (error) {
Client.createAdmin($scope.account.username, $scope.account.password, $scope.account.email, $scope.account.displayName, $scope.setupToken, function (error) {
if (error && error.statusCode === 403) {
$scope.busy = false;
$scope.error = $scope.provider === 'ami' ? 'Wrong instance id' : 'Wrong setup token';
@@ -82,7 +81,6 @@ app.controller('SetupController', ['$scope', '$http', 'Client', function ($scope
$scope.account.displayName = search.displayName || $scope.account.displayName;
$scope.account.requireEmail = !search.email;
$scope.provider = status.provider;
$scope.instanceId = search.instanceId;
$scope.apiServerOrigin = status.apiServerOrigin;
$scope.initialized = true;

View File

@@ -4,11 +4,14 @@
var app = angular.module('Application', ['angular-md5', 'ui-notification', 'ngTld']);
app.controller('SetupDNSController', ['$scope', '$http', 'Client', 'ngTld', function ($scope, $http, Client, ngTld) {
var search = decodeURIComponent(window.location.search).slice(1).split('&').map(function (item) { return item.split('='); }).reduce(function (o, k) { o[k[0]] = k[1]; return o; }, {});
$scope.initialized = false;
$scope.busy = false;
$scope.error = null;
$scope.provider = '';
$scope.showDNSSetup = false;
$scope.instanceId = '';
// keep in sync with certs.js
$scope.dnsProvider = [
@@ -36,7 +39,8 @@ app.controller('SetupDNSController', ['$scope', '$http', 'Client', 'ngTld', func
provider: $scope.dnsCredentials.provider,
accessKeyId: $scope.dnsCredentials.accessKeyId,
secretAccessKey: $scope.dnsCredentials.secretAccessKey,
token: $scope.dnsCredentials.digitalOceanToken
token: $scope.dnsCredentials.digitalOceanToken,
providerToken: $scope.instanceId
};
// special case the wildcard provider
@@ -46,7 +50,11 @@ app.controller('SetupDNSController', ['$scope', '$http', 'Client', 'ngTld', func
}
Client.setupDnsConfig(data, function (error) {
if (error) {
if (error && error.statusCode === 403) {
$scope.dnsCredentials.busy = false;
$scope.error = 'Wrong instance id provided.';
return;
} else if (error) {
$scope.dnsCredentials.busy = false;
$scope.dnsCredentials.error = error.message;
return;
@@ -84,6 +92,7 @@ app.controller('SetupDNSController', ['$scope', '$http', 'Client', 'ngTld', func
$scope.dnsCredentials.provider = 'wildcard';
}
$scope.instanceId = search.instanceId;
$scope.provider = status.provider;
$scope.initialized = true;
});