keycloak-aplcache

Merge pull request #3532 from ssilvert/enter-key KEYCLOAK-3948:

11/21/2016 5:23:21 PM

Details

diff --git a/themes/src/main/resources/theme/base/admin/resources/js/app.js b/themes/src/main/resources/theme/base/admin/resources/js/app.js
index e3b5cc5..3b1172c 100755
--- a/themes/src/main/resources/theme/base/admin/resources/js/app.js
+++ b/themes/src/main/resources/theme/base/admin/resources/js/app.js
@@ -2286,6 +2286,8 @@ module.directive('kcSave', function ($compile, Notifications) {
             elem.addClass("btn btn-primary");
             elem.attr("type","submit");
             elem.bind('click', function() {
+                if ($scope.hasOwnProperty("changed") && !$scope.changed) return;
+                
                 $scope.$apply(function() {
                     var form = elem.closest('form');
                     if (form && form.attr('name')) {
diff --git a/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js b/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
index bf59be0..ed747ae 100755
--- a/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
+++ b/themes/src/main/resources/theme/base/admin/resources/js/controllers/users.js
@@ -535,6 +535,9 @@ module.controller('UserCredentialsCtrl', function($scope, realm, user, $route, R
     });
 
     $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.");
@@ -563,6 +566,10 @@ module.controller('UserCredentialsCtrl', function($scope, realm, user, $route, R
         });
     };
 
+    $scope.passwordAndConfirmPasswordEntered = function() {
+        return $scope.password && $scope.confirmPassword;
+    }
+    
     $scope.disableCredentialTypes = function() {
         Dialog.confirm('Disable credentials', 'Are you sure you want to disable these the users credentials?', function() {
             UserCredentials.disableCredentialTypes({ realm: realm.realm, userId: user.id }, $scope.disableableCredentialTypes, function() {
diff --git a/themes/src/main/resources/theme/base/admin/resources/partials/user-credentials.html b/themes/src/main/resources/theme/base/admin/resources/partials/user-credentials.html
index 1b545f7..d213fdd 100755
--- a/themes/src/main/resources/theme/base/admin/resources/partials/user-credentials.html
+++ b/themes/src/main/resources/theme/base/admin/resources/partials/user-credentials.html
@@ -35,7 +35,7 @@
                 </div>
 
                 <div class="form-group">
-                    <div class="col-md-10 col-md-offset-2" data-ng-show="password && confirmPassword">
+                    <div class="col-md-10 col-md-offset-2" data-ng-show="passwordAndConfirmPasswordEntered()">
                         <button class="btn btn-danger" type="submit" data-ng-click="resetPassword(true)">{{:: 'reset-password' | translate}}</button>
                     </div>
                 </div>
@@ -57,7 +57,7 @@
                 <label class="col-md-2 control-label" for="disableCredentialTypes">{{:: 'disable-credential-types' | translate}}</label>
 
                 <div class="col-md-6">
-                    <button id="disableCredentialTypes" class="btn btn-default" data-ng-click="disableCredentialTypes()">{{:: 'disable' | translate}}</button>
+                    <button type="button" id="disableCredentialTypes" class="btn btn-default" data-ng-click="disableCredentialTypes()">{{:: 'disable' | translate}}</button>
                 </div>
                 <kc-tooltip>{{:: 'credentials.disable.tooltip' | translate}}</kc-tooltip>
             </div>
@@ -79,7 +79,7 @@
                 <label class="col-md-2 control-label" for="reqActionsEmail">{{:: 'reset-actions-email' | translate}}</label>
 
                 <div class="col-md-6">
-                    <button id="reqActionsEmail" class="btn btn-default" data-ng-click="sendExecuteActionsEmail()">{{:: 'send-email' | translate}}</button>
+                    <button type="button" id="reqActionsEmail" class="btn btn-default" data-ng-click="sendExecuteActionsEmail()">{{:: 'send-email' | translate}}</button>
                 </div>
                 <kc-tooltip>{{:: 'credentials.reset-actions-email.tooltip' | translate}}</kc-tooltip>
             </div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html b/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html
index 4062b1c..b3c84c6 100755
--- a/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html
+++ b/themes/src/main/resources/theme/base/admin/resources/templates/kc-component-config.html
@@ -27,7 +27,7 @@
                     <input class="form-control" type="text" data-ng-model="config[ option.name ][0]" >
                 </div>
                 <div class="col-md-2">
-                    <button type="submit" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button>
+                    <button type="button" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button>
                 </div>
             </div>
         </div>
diff --git a/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html b/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html
index 0309bb3..131097b 100755
--- a/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html
+++ b/themes/src/main/resources/theme/base/admin/resources/templates/kc-provider-config.html
@@ -22,7 +22,7 @@
                     <input class="form-control" type="text" data-ng-model="config[ option.name ]" >
                 </div>
                 <div class="col-md-2">
-                    <button type="submit" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button>
+                    <button type="button" data-ng-click="openRoleSelector(option.name, config)" class="btn btn-default" tooltip-placement="top" tooltip-trigger="mouseover mouseout" tooltip="{{:: 'selectRole.tooltip' | translate}}">{{:: 'selectRole.label' | translate}}</button>
                 </div>
             </div>
         </div>