Simplify password validation for cloudron update

This commit is contained in:
Johannes Zellner
2016-01-21 14:53:49 +01:00
parent d186084835
commit e1111ba2bb
2 changed files with 7 additions and 8 deletions

View File

@@ -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>

View File

@@ -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);