Quellcode durchsuchen

fix issue with 'go back' button not working

Jason Rivard vor 7 Jahren
Ursprung
Commit
b698ac8e09

+ 2 - 2
server/src/main/java/password/pwm/http/servlet/forgottenpw/ForgottenPasswordServlet.java

@@ -1525,7 +1525,7 @@ public class ForgottenPasswordServlet extends ControlledPwmServlet
         final List<TokenDestinationItem> destItems = ForgottenPasswordUtil.figureAvailableTokenDestinations( pwmRequest, forgottenPasswordBean );
         pwmRequest.setAttribute( PwmRequestAttribute.TokenDestItems, new ArrayList<>( destItems ) );
 
-        if ( ForgottenPasswordUtil.hasOtherMethodChoices( forgottenPasswordBean, IdentityVerificationMethod.TOKEN ) )
+        if ( ForgottenPasswordUtil.hasOtherMethodChoices( pwmRequest, forgottenPasswordBean, IdentityVerificationMethod.TOKEN ) )
         {
             pwmRequest.setAttribute( PwmRequestAttribute.GoBackAction, ResetAction.clearActionChoice.name() );
         }
@@ -1551,7 +1551,7 @@ public class ForgottenPasswordServlet extends ControlledPwmServlet
         {
             goBackAction = ResetAction.clearTokenDestination;
         }
-        else if ( ForgottenPasswordUtil.hasOtherMethodChoices( forgottenPasswordBean, IdentityVerificationMethod.TOKEN ) )
+        else if ( ForgottenPasswordUtil.hasOtherMethodChoices( pwmRequest, forgottenPasswordBean, IdentityVerificationMethod.TOKEN ) )
         {
             goBackAction = ResetAction.clearActionChoice;
         }

+ 24 - 5
server/src/main/java/password/pwm/http/servlet/forgottenpw/ForgottenPasswordUtil.java

@@ -76,6 +76,7 @@ import javax.servlet.ServletException;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
+import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -856,24 +857,42 @@ public class ForgottenPasswordUtil
         );
     }
 
-    static boolean hasOtherMethodChoices( final ForgottenPasswordBean forgottenPasswordBean, final IdentityVerificationMethod thisMethod )
+    static boolean hasOtherMethodChoices(
+            final PwmRequest pwmRequest,
+            final ForgottenPasswordBean forgottenPasswordBean,
+            final IdentityVerificationMethod thisMethod
+    )
     {
         if ( forgottenPasswordBean.getRecoveryFlags().getRequiredAuthMethods().contains( thisMethod )  )
         {
             return false;
         }
 
-        if ( forgottenPasswordBean.getRecoveryFlags().getMinimumOptionalAuthMethods() > 0 )
         {
-            final Set<IdentityVerificationMethod> satisfiedOptionalMethods = figureSatisfiedOptionalAuthMethods(
-                    forgottenPasswordBean.getRecoveryFlags(), forgottenPasswordBean.getProgress()
+            // check if has previously satisfied any other optional methods.
+            final Set<IdentityVerificationMethod> optionalAuthMethods = forgottenPasswordBean.getRecoveryFlags().getOptionalAuthMethods();
+            final Set<IdentityVerificationMethod> satisfiedMethods = forgottenPasswordBean.getProgress().getSatisfiedMethods();
+            final boolean disJoint = Collections.disjoint( optionalAuthMethods, satisfiedMethods );
+            if ( !disJoint )
+            {
+                return true;
+            }
+        }
+
+        {
+            final Set<IdentityVerificationMethod> remainingAvailableOptionalMethods = ForgottenPasswordUtil.figureRemainingAvailableOptionalAuthMethods(
+                    pwmRequest,
+                    forgottenPasswordBean
             );
+            final Set<IdentityVerificationMethod> otherOptionalMethodChoices = new HashSet<>( remainingAvailableOptionalMethods );
+            otherOptionalMethodChoices.remove( thisMethod );
 
-            if ( satisfiedOptionalMethods.size() < forgottenPasswordBean.getRecoveryFlags().getMinimumOptionalAuthMethods() )
+            if ( !otherOptionalMethodChoices.isEmpty() )
             {
                 return true;
             }
         }
+
         return false;
     }
 }

+ 46 - 41
server/src/main/webapp/WEB-INF/jsp/fragment/form.jsp

@@ -59,7 +59,7 @@
         currentValue = StringUtil.escapeHtml(currentValue);
 
 %>
-<div class="formFieldWrapper">
+<div class="formFieldWrapper" id="formFieldWrapper-<%=loopConfiguration.getName()%>">
     <% if (loopConfiguration.getType().equals(FormConfiguration.Type.hidden)) { %>
     <input id="<%=loopConfiguration.getName()%>" type="hidden" class="inputfield"
            name="<%=loopConfiguration.getName()%>" value="<%= currentValue %>"/>
@@ -102,48 +102,53 @@
         <% } %>
     </select>
     <% } else if (loopConfiguration.getType() == FormConfiguration.Type.photo ) { %>
-    <% if (StringUtil.isEmpty( currentValue) ) { %>
-    <div class="formfield-photo-missing">
+    <div class="formfield-photo-wrapper">
+        <% if (StringUtil.isEmpty( currentValue) ) { %>
+        <div id="<%=loopConfiguration.getName()%>" class="formfield-photo-missing">
+        </div>
+        <% } else { %>
+        <div class="formfield-photo-image-wrapper">
+            <img class="formfield-photo" src="<pwm:current-url/>?processAction=readPhoto&field=<%=loopConfiguration.getName()%>"/>
+        </div>
+        <% } %>
+        <% if (!readonly) { %>
+        <div class="formfield-photo-controls-wrapper">
+            <button type="button" id="button-uploadPhoto-<%=loopConfiguration.getName()%>" name="<%=loopConfiguration.getName()%>" class="btn" title="<pwm:display key="Button_Upload"/>">
+                <pwm:if test="<%=PwmIfTest.showIcons%>"><span class="btn-icon pwm-icon pwm-icon-upload"></span></pwm:if>
+                <pwm:display key="Button_Upload"/>
+            </button>
+            <pwm:script>
+                <script type="application/javascript">
+                    PWM_GLOBAL['startupFunctions'].push(function(){
+                        PWM_MAIN.addEventHandler('button-uploadPhoto-<%=loopConfiguration.getName()%>',"click",function(){
+                            var accept = '<%=StringUtil.collectionToString(loopConfiguration.getMimeTypes())%>';
+                            PWM_UPDATE.uploadPhoto('<%=loopConfiguration.getName()%>',{accept:accept});
+                        });
+                    });
+                </script>
+            </pwm:script>
+            <% if (!StringUtil.isEmpty( currentValue) ) { %>
+            <button type="submit" id="button-deletePhoto-<%=loopConfiguration.getName()%>" name="<%=loopConfiguration.getName()%>" class="btn" title="<pwm:display key="Button_Upload"/>" form="form-deletePhoto-<%=loopConfiguration.getName()%>">
+                <pwm:if test="<%=PwmIfTest.showIcons%>"><span class="btn-icon pwm-icon pwm-icon-times"></span></pwm:if>
+                <pwm:display key="Button_Delete"/>
+            </button>
+            <pwm:script>
+                <script type="application/javascript">
+                    PWM_GLOBAL['startupFunctions'].push(function(){
+                        PWM_MAIN.addEventHandler('button-deletePhoto-<%=loopConfiguration.getName()%>',"click",function(){
+                            PWM_MAIN.showConfirmDialog({okAction:function(){
+                                    PWM_MAIN.submitPostAction(window.location.pathname, 'deletePhoto', {field:'<%=loopConfiguration.getName()%>'});
+                                }
+                            })
+                        });
+                    });
+                </script>
+            </pwm:script>
+            <% } %>
+        </div>
+        <% } %>
     </div>
     <% } else { %>
-    <img class="formfield-photo" src="<pwm:current-url/>?processAction=readPhoto&field=<%=loopConfiguration.getName()%>"/>
-    <% } %>
-    <br/>
-    <% if (!readonly) { %>
-    <a id="button-uploadPhoto-<%=loopConfiguration.getName()%>" name="<%=loopConfiguration.getName()%>" class="btn" title="<pwm:display key="Button_Upload"/>">
-        <pwm:if test="<%=PwmIfTest.showIcons%>"><span class="btn-icon pwm-icon pwm-icon-upload"></span></pwm:if>
-        <pwm:display key="Button_Upload"/>
-    </a>
-    <pwm:script>
-        <script type="application/javascript">
-            PWM_GLOBAL['startupFunctions'].push(function(){
-                PWM_MAIN.addEventHandler('button-uploadPhoto-<%=loopConfiguration.getName()%>',"click",function(){
-                    var accept = '<%=StringUtil.collectionToString(loopConfiguration.getMimeTypes())%>';
-                    PWM_UPDATE.uploadPhoto('<%=loopConfiguration.getName()%>',{accept:accept});
-                });
-            });
-        </script>
-    </pwm:script>
-    <% if (!StringUtil.isEmpty( currentValue) ) { %>
-    <button type="submit" id="button-deletePhoto-<%=loopConfiguration.getName()%>" name="<%=loopConfiguration.getName()%>" class="btn" title="<pwm:display key="Button_Upload"/>" form="form-deletePhoto-<%=loopConfiguration.getName()%>">
-        <pwm:if test="<%=PwmIfTest.showIcons%>"><span class="btn-icon pwm-icon pwm-icon-times"></span></pwm:if>
-        <pwm:display key="Button_Delete"/>
-    </button>
-    <pwm:script>
-        <script type="application/javascript">
-            PWM_GLOBAL['startupFunctions'].push(function(){
-                PWM_MAIN.addEventHandler('button-deletePhoto-<%=loopConfiguration.getName()%>',"click",function(){
-                    PWM_MAIN.showConfirmDialog({okAction:function(){
-                            PWM_MAIN.submitPostAction(window.location.pathname, 'deletePhoto', {field:'<%=loopConfiguration.getName()%>'});
-                        }
-                    })
-                });
-            });
-        </script>
-    </pwm:script>
-    <% } %>
-    <% } %>
-    <% } else { %>
     <input id="<%=loopConfiguration.getName()%>" type="<%=loopConfiguration.getType()%>" class="inputfield"
            name="<%=loopConfiguration.getName()%>" value="<%= currentValue %>"
     <pwm:if test="<%=PwmIfTest.clientFormShowRegexEnabled%>">

+ 2 - 2
server/src/main/webapp/WEB-INF/jsp/fragment/token-form-field.jsp

@@ -27,8 +27,8 @@
 <%@ taglib uri="pwm" prefix="pwm" %>
 <h2><label for="<%=PwmConstants.PARAM_TOKEN%>"><pwm:display key="Field_Code"/></label></h2>
 <pwm:if test="<%=PwmIfTest.maskTokenInput%>">
-    <input type="password" class="inputfield passwordfield" id="<%=PwmConstants.PARAM_TOKEN%>" name="<%=PwmConstants.PARAM_TOKEN%>" required="required" <pwm:autofocus/> ></textarea>
+    <input type="password" class="inputfield passwordfield" id="<%=PwmConstants.PARAM_TOKEN%>" name="<%=PwmConstants.PARAM_TOKEN%>" <pwm:autofocus/> ></textarea>
 </pwm:if>
 <pwm:if test="<%=PwmIfTest.maskTokenInput%>" negate="true">
-    <textarea id="<%=PwmConstants.PARAM_TOKEN%>" name="<%=PwmConstants.PARAM_TOKEN%>" class="tokenInput" required="required" <pwm:autofocus/> ></textarea>
+    <textarea id="<%=PwmConstants.PARAM_TOKEN%>" name="<%=PwmConstants.PARAM_TOKEN%>" class="tokenInput" <pwm:autofocus/> ></textarea>
 </pwm:if>

+ 12 - 10
server/src/main/webapp/public/resources/js/main.js

@@ -281,17 +281,19 @@ PWM_MAIN.applyFormAttributes = function() {
     });
 
     // handle html5 form attribute in JS in case browser (IE) doesn't support it.
-    PWM_MAIN.doQuery("button[type=submit][form]",function(element){
-        console.log('added event handler for submit button with form attribute ' + element.id);
-        /*
-        PWM_MAIN.addEventHandler(element,'click',function(e){
-            PWM_MAIN.stopEvent(e);
-            PWM_VAR['dirtyPageLeaveFlag'] = false;
-            var formID = element.getAttribute('form');
-            PWM_MAIN.handleFormSubmit(PWM_MAIN.getObject(formID));
+    if(dojo.isIE) {
+        PWM_MAIN.doQuery("button[type=submit][form]", function (element) {
+            /*
+            console.log('added event handler for submit button with form attribute ' + element.id);
+            PWM_MAIN.addEventHandler(element,'click',function(e){
+                PWM_MAIN.stopEvent(e);
+                PWM_VAR['dirtyPageLeaveFlag'] = false;
+                var formID = element.getAttribute('form');
+                PWM_MAIN.handleFormSubmit(PWM_MAIN.getObject(formID));
+            });
+            */
         });
-        */
-    });
+    }
 };
 
 PWM_MAIN.preloadAll = function(nextFunction) {