Remove Client.isServerFirstTime()
This commit is contained in:
@@ -307,13 +307,6 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
|
|||||||
}).error(defaultErrorHandler(callback));
|
}).error(defaultErrorHandler(callback));
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.prototype.isServerFirstTime = function (callback) {
|
|
||||||
$http.get(client.apiOrigin + '/api/v1/cloudron/status').success(function(data, status) {
|
|
||||||
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
|
||||||
callback(null, !data.activated);
|
|
||||||
}).error(defaultErrorHandler(callback));
|
|
||||||
};
|
|
||||||
|
|
||||||
Client.prototype.getStatus = function (callback) {
|
Client.prototype.getStatus = function (callback) {
|
||||||
$http.get(client.apiOrigin + '/api/v1/cloudron/status').success(function(data, status) {
|
$http.get(client.apiOrigin + '/api/v1/cloudron/status').success(function(data, status) {
|
||||||
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
if (status !== 200 || typeof data !== 'object') return callback(new ClientError(status, data));
|
||||||
|
|||||||
@@ -67,9 +67,9 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Client.isServerFirstTime(function (error, isFirstTime) {
|
Client.getStatus(function (error, status) {
|
||||||
if (error) return $scope.error(error);
|
if (error) return $scope.error(error);
|
||||||
if (isFirstTime) return $scope.setup();
|
if (!status.activated) return $scope.setup();
|
||||||
|
|
||||||
Client.refreshConfig(function (error) {
|
Client.refreshConfig(function (error) {
|
||||||
if (error) return $scope.error(error);
|
if (error) return $scope.error(error);
|
||||||
|
|||||||
+23
-16
@@ -249,31 +249,38 @@ app.controller('SetupController', ['$scope', '$location', 'Client', 'Wizard', fu
|
|||||||
// Stupid angular location provider either wants html5 location mode or not, do the query parsing on my own
|
// Stupid angular location provider either wants html5 location mode or not, do the query parsing on my own
|
||||||
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; }, {});
|
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; }, {});
|
||||||
|
|
||||||
if (!search.setupToken) return window.location.href = '/error.html?errorCode=2';
|
Client.getStatus(function (error, status) {
|
||||||
$scope.setupToken = search.setupToken;
|
|
||||||
|
|
||||||
if (!search.email) return window.location.href = '/error.html?errorCode=3';
|
|
||||||
Wizard.email = search.email;
|
|
||||||
|
|
||||||
if (search.customDomain === 'true') {
|
|
||||||
Wizard.dnsConfig = {
|
|
||||||
provider: 'route53',
|
|
||||||
accessKeyId: null,
|
|
||||||
secretAccessKey: null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
Client.isServerFirstTime(function (error, isFirstTime) {
|
|
||||||
if (error) {
|
if (error) {
|
||||||
window.location.href = '/error.html';
|
window.location.href = '/error.html';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isFirstTime) {
|
if (status.activated) {
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!search.setupToken) {
|
||||||
|
window.location.href = '/error.html?errorCode=2';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!search.email) {
|
||||||
|
window.location.href = '/error.html?errorCode=3';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.setupToken = search.setupToken;
|
||||||
|
Wizard.email = search.email;
|
||||||
|
|
||||||
|
if (search.customDomain === 'true') {
|
||||||
|
Wizard.dnsConfig = {
|
||||||
|
provider: 'route53',
|
||||||
|
accessKeyId: null,
|
||||||
|
secretAccessKey: null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
$location.path('/step1');
|
$location.path('/step1');
|
||||||
|
|
||||||
$scope.initialized = true;
|
$scope.initialized = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user