I want to show an error message when the admin entered spaces either in beginning or end of the password fields. But i noticed that the returned password when i click the reset button automatically removes the whitespaces in beginning or in the end of the string. Only the spaces in between are detected.
I did an inspect element on the pw fields and i saw this lines.
<legend><span class="text ng-binding">Manage Password</span></legend>
<div class="form-group">
<label class="col-md-2 control-label ng-binding" for="newPas">New Password
<span class="required ng-hide" data-ng-show="create">*</span></label>
<div class="col-md-6">
<input class="form-control password-conceal ng-not-empty ng-dirty ng-valid-parse
ng-valid ng-valid-required ng-touched" kc-password="" type="text" id="newPas"
name="newPas" data-ng-model="password" required="">
But when i search it on the keycloak files i saw they are different.
<legend><span class="text">{{:: 'manage-user-password' | translate}}</span></legend>
<div class="form-group">
<label class="col-md-2 control-label" for="newPas">{{:: 'new-password' | translate}}
<span class="required" data-ng-show="create">*</span></label>
<div class="col-md-6">
<input class="form-control" kc-password type="text"
id="newPas" name="newPas" data-ng-model="password" required>
Here is the full html file: https://github.com/keycloak/keycloak/blob/master/themes/src/main/resources/theme/base/admin/resources/partials/user-credentials.html
And here is angularjs code that it uses:
$scope.resetPassword = function() {
// hit enter without entering both fields - ignore
if (!$scope.passwordAndConfirmPasswordEntered()) return;
if ($scope.pwdChange) {
if ($scope.password != $scope.confirmPassword) {
Notifications.error("Password and confirmation does not match.");
return;
}
}
var msgTitle = 'Change password';
var msg = 'Are you sure you want to change the users password?';
Dialog.confirm(msgTitle, msg, function() {
UserCredentials.resetPassword({ realm: realm.realm, userId: user.id },
{ type : "password", value : $scope.password, temporary: $scope.temporaryPassword }, function() {
Notifications.success("The password has been reset test"+$scope.password);
//here i confirmed that the returned password automatically removes the spaces in beginning and end.
Only spaces in between are accepted.
$scope.password = null;
$scope.confirmPassword = null;
$route.reload();
});
}, function() {
$scope.password = null;
$scope.confirmPassword = null;
});
};
$scope.passwordAndConfirmPasswordEntered = function() {
return $scope.password && $scope.confirmPassword;
}
Here is the full js scripts: https://github.com/keycloak/keycloak/blob/master/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
Please help me to locate how does keycloak removes the spaces i entered in beginning or end of the password! thanks