ask password only for destructive actions

This commit is contained in:
Girish Ramakrishnan
2017-09-08 14:56:18 -07:00
parent 3240a71feb
commit d233ee2a83
6 changed files with 12 additions and 65 deletions

View File

@@ -345,10 +345,9 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.configureApp = function (id, password, config, callback) {
Client.prototype.configureApp = function (id, config, callback) {
var data = {
appId: id,
password: password,
location: config.location,
portBindings: config.portBindings,
accessRestriction: config.accessRestriction,
@@ -367,10 +366,9 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.updateApp = function (id, manifest, portBindings, password, callback) {
Client.prototype.updateApp = function (id, manifest, portBindings, callback) {
var data = {
appStoreId: manifest.id + '@' + manifest.version,
password: password,
portBindings: portBindings
};
@@ -821,8 +819,8 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.update = function (password, callback) {
var data = { password: password };
Client.prototype.update = function (callback) {
var data = { };
post('/api/v1/cloudron/update', data).success(function(data, status) {
if (status !== 202 || typeof data !== 'object') return callback(new ClientError(status, data));

View File

@@ -12,8 +12,7 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.update = {
busy: false,
error: {},
password: ''
error: {}
};
$scope.isActive = function (url) {
@@ -77,8 +76,6 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.showUpdateModal = function (form) {
$scope.update.error.generic = null;
$scope.update.error.password = null;
$scope.update.password = '';
form.$setPristine();
form.$setUntouched();
@@ -98,21 +95,12 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
$scope.doUpdate = function () {
$scope.update.error.generic = null;
$scope.update.error.password = null;
$scope.update.busy = true;
Client.update($scope.update.password, function (error) {
Client.update(function (error) {
if (error) {
if (error.statusCode === 403) {
$scope.update.error.password = true;
$scope.update.password = '';
$scope.update_form.password.$setPristine();
$('#inputUpdatePassword').focus();
} else if (error.statusCode === 409) {
if (error.statusCode === 409) {
$scope.update.error.generic = 'Please try again later. The Cloudron is creating a backup at the moment.';
$scope.update.password = '';
$scope.update_form.password.$setPristine();
$('#inputUpdatePassword').focus();
} else {
$scope.update.error.generic = error.message;
console.error('Unable to update.', error);