From 62000e042d8e03006bd659ac719e51b11dce207e Mon Sep 17 00:00:00 2001 From: Stan Silvert Date: Thu, 20 Apr 2017 18:09:20 -0400 Subject: [PATCH] KEYCLOAK-4402: Fix regexp password policy. --- .../theme/base/admin/resources/js/controllers/realm.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js index b56bcc9a61..bcb0d0c211 100644 --- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js +++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/realm.js @@ -468,12 +468,14 @@ module.controller('RealmPasswordPolicyCtrl', function($scope, Realm, realm, $htt value = null; } else { id = policyToken.substring(0, policyToken.indexOf('(')); - value = policyToken.substring(policyToken.indexOf('(') + 1, policyToken.indexOf(')')).trim(); + value = policyToken.substring(policyToken.indexOf('(') + 1, policyToken.lastIndexOf(')')).trim(); } for (var j = 0; j < serverInfo.passwordPolicies.length; j++) { if (serverInfo.passwordPolicies[j].id == id) { - var p = serverInfo.passwordPolicies[j]; + // clone + var p = JSON.parse(JSON.stringify(serverInfo.passwordPolicies[j])); + p.value = value && value || p.defaultValue; policies.push(p); } @@ -502,6 +504,7 @@ module.controller('RealmPasswordPolicyCtrl', function($scope, Realm, realm, $htt $scope.serverInfo = serverInfo; $scope.changed = false; + console.log(JSON.stringify(parse(realm.passwordPolicy))); $scope.policy = parse(realm.passwordPolicy); var oldCopy = angular.copy($scope.policy);