Add form validation for scopes

This commit is contained in:
Johannes Zellner
2016-06-07 16:10:33 +02:00
parent a0227b6043
commit 234caa60eb
2 changed files with 6 additions and 2 deletions

View File

@@ -122,7 +122,7 @@
<small ng-show="clientAddForm.scope.$error.required">A scope is required</small>
<small ng-show="!clientAddForm.scope.$dirty && clientAdd.error.scope">{{ clientAdd.error.scope }}</small>
</div>
<input type="text" class="form-control" ng-model="clientAdd.scope" name="scope" required>
<input type="text" class="form-control" ng-model="clientAdd.scope" name="scope" id="clientAddScope" required>
</div>
<div class="form-group" ng-class="{ 'has-error': (clientAddForm.redirectURI.$dirty && clientAddForm.redirectURI.$invalid) || (!clientAddForm.redirectURI.$dirty && clientAdd.error.redirectURI) }">
<label class="control-label">Redirect URI</label>

View File

@@ -191,8 +191,12 @@ angular.module('Application').controller('AccountController', ['$scope', '$locat
$scope.clientAdd.error.redirectURI = error.message;
$scope.clientAddForm.redirectURI.$setPristine();
$('#clientAddRedirectURI').focus();
} else if (error.message.indexOf('Invalid scope') === 0) {
$scope.clientAdd.error.scope = error.message;
$scope.clientAddForm.scope.$setPristine();
$('#clientAddScope').focus();
} else {
// TODO scope checking
console.error(error);
}
return;
}