Remove password requirement for app uninstall and restore

This commit is contained in:
Johannes Zellner
2019-05-13 23:31:45 +02:00
parent 7c2ea6288c
commit b67d5eec3d
3 changed files with 23 additions and 65 deletions

View File

@@ -398,8 +398,8 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
});
};
Client.prototype.restoreApp = function (appId, backupId, password, callback) {
var data = { password: password, backupId: backupId };
Client.prototype.restoreApp = function (appId, backupId, callback) {
var data = { backupId: backupId };
post('/api/v1/apps/' + appId + '/restore', data, null, function (error, data, status) {
if (error) return callback(error);
@@ -420,8 +420,8 @@ angular.module('Application').service('Client', ['$http', '$interval', 'md5', 'N
});
};
Client.prototype.uninstallApp = function (appId, password, callback) {
var data = { password: password };
Client.prototype.uninstallApp = function (appId, callback) {
var data = {};
post('/api/v1/apps/' + appId + '/uninstall', data, null, function (error, data, status) {
if (error) return callback(error);

View File

@@ -256,16 +256,6 @@
<i style="margin-left: 10px;" class="fa fa-copy hand" uib-tooltip="{{ appRestore.copyBackupIdDone ? 'Copied to clipboard' : 'Click to copy backup id' }}" tooltip-placement="right" ng-click="appRestore.copyBackupId()"></i>
</div>
<br/>
<fieldset>
<form role="form" ng-submit="appRestore.restore()" autocomplete="off">
<div class="form-group" ng-class="{ 'has-error': appRestore.error.password }">
<label class="control-label" for="appRestorePasswordInput">Provide your password to confirm this action</label>
<div ng-show="appRestore.error.password"><small>Wrong password</small></div>
<input type="password" class="form-control" ng-model="appRestore.password" id="appRestorePasswordInput" name="password" required autofocus>
</div>
<input class="ng-hide" type="submit" ng-disabled="!appRestore.password || appRestore.busy || !appRestore.selectedBackup"/>
</form>
</fieldset>
</div>
</uib-tab>
@@ -334,7 +324,7 @@
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" ng-click="appRestore.clone()" ng-show="appRestore.action === 'clone' && appRestore.backups.length !== 0" ng-disabled="appRestore.busy || !appRestore.selectedBackup"><i class="fa fa-circle-notch fa-spin" ng-show="appRestore.busy"></i> Clone</button>
<button type="button" class="btn btn-danger" ng-click="appRestore.restore()" ng-show="appRestore.action === 'restore' && appRestore.backups.length !== 0" ng-disabled="!appRestore.password || appRestore.busy || !appRestore.selectedBackup"><i class="fa fa-circle-notch fa-spin" ng-show="appRestore.busy"></i> Restore</button>
<button type="button" class="btn btn-danger" ng-click="appRestore.restore()" ng-show="appRestore.action === 'restore' && appRestore.backups.length !== 0" ng-disabled="appRestore.busy || !appRestore.selectedBackup"><i class="fa fa-circle-notch fa-spin" ng-show="appRestore.busy"></i> Restore</button>
</div>
</div>
</div>
@@ -431,34 +421,20 @@
<!-- Modal uninstall app -->
<div class="modal fade" id="appUninstallModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Really uninstall {{ appUninstall.app.fqdn }} ?</h4>
</div>
<div class="modal-body">
<p>Deleting the app will also remove all it's data!</p>
<fieldset>
<form role="form" name="appUninstallForm" ng-submit="doUninstall()" autocomplete="off">
<div class="form-group" ng-class="{ 'has-error': (appUninstallForm.password.$dirty && appUninstallForm.password.$invalid) || (!appUninstallForm.password.$dirty && appUninstall.error.password) }">
<label class="control-label" for="appUninstallPasswordInput">Provide your password to confirm this action</label>
<div class="control-label" ng-show="(appUninstallForm.password.$dirty && appUninstallForm.password.$invalid) || (!appUninstallForm.password.$dirty && appUninstall.error.password)">
<small ng-show=" appUninstallForm.password.$dirty && appUninstallForm.password.$invalid">Password required</small>
<small ng-show="!appUninstallForm.password.$dirty && appUninstall.error.password">Wrong password</small>
</div>
<input type="password" class="form-control" ng-model="appUninstall.password" id="appUninstallPasswordInput" name="password" required autofocus>
</div>
<input class="ng-hide" type="submit" ng-disabled="appUninstallForm.$invalid || busy"/>
</form>
</fieldset>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="doUninstall()" ng-disabled="appUninstallForm.$invalid || appUninstall.busy"><i class="fa fa-circle-notch fa-spin" ng-show="appUninstall.busy"></i> Uninstall</button>
</div>
</div>
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Really uninstall {{ appUninstall.app.fqdn }} ?</h4>
</div>
<div class="modal-body">
<p>Deleting the app will also remove all it's data!</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="doUninstall()" ng-disabled="appUninstall.busy"><i class="fa fa-circle-notch fa-spin" ng-show="appUninstall.busy"></i> Uninstall</button>
</div>
</div>
</div>
</div>
<!-- Modal update app -->

View File

@@ -239,8 +239,7 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.appUninstall = {
busy: false,
error: {},
app: {},
password: ''
app: {}
};
$scope.appRestore = {
@@ -248,7 +247,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
busyFetching: false,
error: {},
app: {},
password: '',
backups: [ ],
selectedBackup: null,
@@ -370,14 +368,9 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
restore: function () {
$scope.appRestore.busy = true;
$scope.appRestore.error.password = null;
Client.restoreApp($scope.appRestore.app.id, $scope.appRestore.selectedBackup.id, $scope.appRestore.password, function (error) {
if (error && error.statusCode === 403) {
$scope.appRestore.password = '';
$scope.appRestore.error.password = true;
$('#appRestorePasswordInput').focus();
} else if (error) {
Client.restoreApp($scope.appRestore.app.id, $scope.appRestore.selectedBackup.id, function (error) {
if (error) {
Client.error(error);
} else {
$('#appRestoreModal').modal('hide');
@@ -471,10 +464,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
// reset uninstall dialog
$scope.appUninstall.app = {};
$scope.appUninstall.error = {};
$scope.appUninstall.password = '';
$scope.appUninstallForm.$setPristine();
$scope.appUninstallForm.$setUntouched();
// reset update dialog
$scope.appUpdate.error = {};
@@ -484,7 +473,6 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
// reset restore dialog
$scope.appRestore.error = {};
$scope.appRestore.app = {};
$scope.appRestore.password = '';
$scope.appRestore.selectedBackup = null;
$scope.appRestore.backups = [];
$scope.appRestore.location = '';
@@ -559,15 +547,9 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
$scope.doUninstall = function () {
$scope.appUninstall.busy = true;
$scope.appUninstall.error.password = null;
Client.uninstallApp($scope.appUninstall.app.id, $scope.appUninstall.password, function (error) {
if (error && error.statusCode === 403) {
$scope.appUninstall.password = '';
$scope.appUninstall.error.password = true;
$scope.appUninstallForm.password.$setPristine();
$('#appUninstallPasswordInput').focus();
} else if (error && error.statusCode === 402) { // unpurchase failed
Client.uninstallApp($scope.appUninstall.app.id, function (error) {
if (error && error.statusCode === 402) { // unpurchase failed
Client.error('Relogin to Cloudron App Store');
} else if (error) {
Client.error(error);