Simplify password validation for cloudron update
This commit is contained in:
@@ -86,15 +86,13 @@
|
||||
<br/>
|
||||
<fieldset>
|
||||
<form name="update_form" role="form" ng-submit="doUpdate()" autocomplete="off">
|
||||
<div class="form-group" ng-class="{ 'has-error': update_form.password.$dirty && update_form.password.$invalid }">
|
||||
<div class="form-group" ng-class="{ 'has-error': (update_form.password.$dirty && update_form.password.$invalid) || (!update_form.password.$dirty && update.error.password) }">
|
||||
<label class="control-label" for="inputUpdatePassword">Give your password to verify that you are performing that action</label>
|
||||
<div class="control-label" ng-show="(!update_form.password.$dirty && update.error.password) || (update_form.password.$dirty && update_form.password.$invalid)">
|
||||
<small ng-show="update_form.password.$error.required && !update.error.password">A password is required</small>
|
||||
<small ng-show="update_form.password.$error.minlength">The password is too short</small>
|
||||
<small ng-show="update_form.password.$error.maxlength">The password is too long</small>
|
||||
<small ng-show="update.error.password">Incorrect password</small>
|
||||
<div class="control-label" ng-show="(update_form.password.$dirty && update_form.password.$invalid) || (!update_form.password.$dirty && update.error.password)">
|
||||
<small ng-show=" update_form.password.$dirty && update_form.password.$invalid">Password required</small>
|
||||
<small ng-show="!update_form.password.$dirty && update.error.password">Invalid password</small>
|
||||
</div>
|
||||
<input type="password" class="form-control" ng-model="update.password" id="inputUpdatePassword" name="password" placeholder="Password" ng-maxlength="30" ng-minlength="8" required autofocus>
|
||||
<input type="password" class="form-control" ng-model="update.password" id="inputUpdatePassword" name="password" placeholder="Password" required autofocus>
|
||||
</div>
|
||||
<input class="ng-hide" type="submit" ng-disabled="update_form.$invalid || update.busy"/>
|
||||
</form>
|
||||
|
||||
@@ -54,8 +54,9 @@ angular.module('Application').controller('MainController', ['$scope', '$route',
|
||||
Client.update($scope.update.password, function (error) {
|
||||
if (error) {
|
||||
if (error.statusCode === 403) {
|
||||
$scope.update.error.password = 'Incorrect password';
|
||||
$scope.update.error.password = true;
|
||||
$scope.update.password = '';
|
||||
$scope.update_form.password.$setPristine();
|
||||
$('#inputUpdatePassword').focus();
|
||||
} else {
|
||||
console.error('Unable to update.', error);
|
||||
|
||||
Reference in New Issue
Block a user