Changeset 32372 for main/trunk


Ignore:
Timestamp:
2018-08-23T14:21:01+12:00 (6 years ago)
Author:
kjdon
Message:

upgraded to recaptcha version 2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/authen.xsl

    r31072 r32372  
    1111    <xsl:import href="layouts/main.xsl"/>
    1212    <xsl:output method="html"/>
    13    
    14     <!-- set page title -->
     13
     14    <!-- add recaptcha js to the head -->
     15  <xsl:template name="additionalHeaderContent-page">
     16    <script src='https://www.google.com/recaptcha/api.js'><xsl:text> </xsl:text></script>
     17  </xsl:template>
     18
     19  <!-- set page title -->
    1520    <xsl:template name="pageTitle">
    1621        <xsl:choose>
     
    200205                                <xsl:when test="/page/pageResponse/authenticationNode/service/@operation = 'AccountSettings'">
    201206                                    <tr>                                       
    202                                         <xsl:if test="not(/page/pageResponse/error/@type = 'Incorrect Password')">
     207                                        <xsl:if test="not(/page/pageResponse/error/@type = 'INCORRECT_PASSWORD')">
    203208                                            <td><button id="changePasswordButton"><xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.change_password')"/>...</button></td>
    204209                                            <script type="text/javascript">
     
    236241                                   
    237242                                    <xsl:choose>
    238                                         <xsl:when test="not(/page/pageResponse/error/@type = 'Incorrect Password')">
     243                                        <xsl:when test="not(/page/pageResponse/error/@type = 'INCORRECT_PASSWORD')">
    239244                                            <tr>
    240245                                                <td id="oldPasswordLabelCell"><xsl:text> </xsl:text></td>
     
    372377                <xsl:when test="/page/pageResponse/authenticationNode/service/@operation = 'AddUser' or /page/pageResponse/authenticationNode/service/@operation = 'Register'">
    373378                    <div id="errorArea"><xsl:text> </xsl:text></div>
    374                     <form method="POST">
     379                    <form method="POST" id="registerForm">
    375380                        <xsl:attribute name="action">
    376381                            <xsl:choose>
     
    464469                                </tr>
    465470                            </xsl:if>
    466                             <xsl:if test="/page/pageResponse/authenticationNode/service/@operation = 'Register' and /page/pageResponse/recaptcha/@privateKey and /page/pageResponse/recaptcha/@publicKey">
    467                                 <tr>
    468                                     <td colspan="2" id="recaptchaArea">
    469                                         <xsl:value-of disable-output-escaping="yes" select="util:reCAPTCHAimage(/page/pageResponse/recaptcha/@publicKey, /page/pageResponse/recaptcha/@privateKey)"/>
    470                                     </td>
    471                                     <script type="text/javascript">
    472                                         <xsl:text disable-output-escaping="yes">
    473                                             function changeParams()
    474                                             {
    475                                                 $("#recaptcha_challenge_field").attr("name", "s1.recaptcha_challenge_field");
    476                                                 $("#recaptcha_response_field").attr("name", "s1.recaptcha_response_field");
    477                                             }
    478                                             $(window).load(changeParams);
    479                                            
    480                                             function checkreCaptchaError()
    481                                             {
    482                                                 var html = $("#recaptchaArea").html();
    483                                                 if(html.search(/Invalid referer/g) != -1)
    484                                                 {
    485                                                     $("#recaptchaArea").html("");
    486                                                     $("#errorArea").html("The reCAPTCHA key used in the siteconfig.xml file for this site is invalid for this domain name. Please contact your collection administrator.");
    487                                                     $("#errorArea").attr("class", "ui-state-error ui-corner-all");
    488                                                 }
    489                                             }
    490                                             $(window).load(checkreCaptchaError);
     471                            <tr>
     472                              <td colspan="2">
     473                            <div class="g-recaptcha" data-sitekey="6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI"><xsl:text> </xsl:text></div></td></tr>
     474                            <tr>
     475                              <td>
     476                                <!-- need to add s1. to the name of g-recaptcha-response, so that it gets passed to the service -->
     477                                  <script type="text/javascript">
     478                                    <xsl:text disable-output-escaping="yes">
     479                                        $( "#registerForm").submit(function( event ) {
     480                                        var captchaelem = $("#g-recaptcha-response");
     481                                        captchaelem.attr("name", "s1.g-recaptcha-response");
     482                                        return true;
     483                                        });
     484                                       
    491485                                        </xsl:text>
    492486                                    </script>
    493                                 </tr>
    494                             </xsl:if>
    495                             <tr>
    496                                 <td>
    497487                                    <input id="submitButton" type="submit" value="{util:getInterfaceText($interface_name, /page/@lang, 'authen.submit')}"/>
    498                                     <script type="text/javascript">
    499                                         <xsl:text disable-output-escaping="yes">
    500                                             $("#submitButton").click(function()
    501                                             {
    502                                                 var passwordOne = $("#passwordOne");
    503                                                 var passwordTwo = $("#passwordTwo");
    504                                                
    505                                                 if(passwordOne.val() != passwordTwo.val())
    506                                                 {
    507                                                     alert("The passwords you have entered do not match");
    508                                                     return false;
    509                                                 }
    510                                                 else
    511                                                 {
    512                                                     return true;
    513                                                 }
    514                                             });
    515                                         </xsl:text>
    516                                     </script>
    517488                                </td>
    518489                            </tr>
     
    535506                    </xsl:choose>
    536507                </xsl:when>
    537                
     508
     509                <xsl:when test="/page/pageResponse/authenticationNode/service/@operation = 'Info'">
     510                  <!-- do nothing -->
     511                </xsl:when>
    538512                <xsl:otherwise>
    539513                    <xsl:value-of select="util:getInterfaceText($interface_name, /page/@lang, 'authen.page_not_found')"/>
Note: See TracChangeset for help on using the changeset viewer.