We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10529
    • 73 Posts
    Hi there - have been working on a project using Webloginpe with 1.02

    The basis of my project was based on the Manual Verification Thread http://modxcms.com/forums/index.php/topic,41231.0.html think I’ve spent the last five days on that thread huh

    Anyway hopefully this thread will help other people get to where I am and maybe someone can just add the final touch and we’ll get the whole thing workking rolleyes

    You can see this live and test it yourselves.

    To get this all to work I had to download the beta version of * WebLoginPE Snippet 1.3.2 Beta 1 from here http://code.google.com/p/webloginpe/downloads/list

    I also had to add a new user group Pending Users as well as another group Subscriber


    The initial login page is here http://www.dementiacarematters.com/g5.html using

    [!WebLoginPE? &type=`simple` &loginFormTpl=`loginForm` &liHomeId=`113` !]


    by loging in as Subscriber & password butterfly1234 you will end up here http://www.dementiacarematters.com/index.php?id=113 on this page you can logout.

    From the initial Login page you will see a link to Register - this will take you to http://www.dementiacarematters.com/registration.html

    using
    [!WebLoginPE? &type=`register` &regType=`pending` &registerTpl=`registerForm` &notifyTpl=`notifyMessage` &regSuccessId=`115` &groups=`Pending Users` &regSuccessPause=`0` &notify=`[email protected]`!]


    and the registerform code
    [+wlpe.message+]
    <div id="wlpeNewUser">
    	<form id="wlpeUserRegisterForm" action="[~[*id*]~]" method="POST" enctype="multipart/form-data">
    		<fieldset id="wlpeUserRegisterInput">
    			<div id="wlpeNewUserInfo">
    				<p id="wlpeRegisterInfo">Use this form to register for a new user account.<br />
    					<span class="info">Fields marked with <span class="required">*</span> are required.</span>
    				</p>
    			</div>
    			<h3>Register for a new user account</h3>
    			<label for="wlpeUserRegisterEmail"><span class="required">*</span> Email
    			<input id="wlpeUserRegisterEmail" type="text" name="email" value="[+post.email+]" />
    			</label>
    <br>
    			<label for="wlpeUserRegisterUserName"><span class="required">*</span> Desired User Name
    			<input id="wlpeUserRegisterUserName" type="text" name="username" value="[+post.username+]" />
    			</label>
    <br>
    			<label for="wlpeUserRegisterFullName"><span class="required">*</span> Full Name
    			<input id="wlpeUserRegisterFullName" type="text" name="fullname" value="[+post.fullname+]" />
    			</label>
    <br>
    			<label for="wlpeUserRegisterPassword"><span class="required">*</span> Password
    			<input id="wlpeUserRegisterPassword" type="password" name="password" value="[+post.password+]" />
    			</label>
    <br>
    			<label for="wlpeUserRegisterPasswordConfirm"><span class="required">*</span> Password (confirm)
    			<input id="wlpeUserRegisterPasswordConfirm" type="password" name="passwordconfirm" value="[+post.passwordconfirm+]" />
    			</label>
    <br>			
    			<img id="wlpeCaptchaImage" src="[+form.captcha+]" width="148" height="60" alt="If you have trouble reading the code, click on the code itself to generate a new random code." />
    			
    			<label for="wlpeUserRegisterCaptcha" id="wlpeCaptchaLabel"><span class="required">*</span>Please enter the code in the image.
    			<input type="text" id="wlpeUserRegisterCaptcha" name="formcode" >
    			</label>
    			
    		
    			
    		</fieldset>
    		<fieldset id="wlpeUserRegisterButtons">
    			<button type="submit" id="wlpeSaveRegisterButton" name="service" value="register">Register</button>
    			<button type="submit" id="wlpeCancelRegisterButton" name="service" value="cancel">Cancel</button>
    		</fieldset>
    	</form>
    </div>


    On registering you will be taken to http://www.dementiacarematters.com/index.php?id=115

    Which explains that the registration has to be validated

    The new Registration shows up in Web Users in a Group Pending Users - I then receive an email with New Web User for Dementia Care Matter in the subject line and this in the body text
    Hello, my name is Gavin Test2 and I just signed up at as "Test2" using WebLoginPE.
    My email address is [email protected].
    P.S. This message was auto generated by WebLoginPE and PHPMailer.

    I then have set up an approval page http://www.dementiacarematters.com/index.php?id=116 where you can see the pending registrations using this
    [!WebLoginPE? &type=`manager` &activateId=`117` &groupsField=`usergroup` &manageTpl=`approvemanageUsersForm` &usersList=`The following accounts require approval:default:default:username:ASC:webgroup(Pending Users)`!]


    and the chunk which also moves the user from pending to Subscriber
    [+wlpe.message+]
    <div id="wlpeUser">
    	<form enctype="multipart/form-data" id="wlpeUserProfileForm" action="[~[*id*]~]" method="POST">
    		<fieldset id="wlpeUserProfileInput">
    			<div id="wlpeUserInfo">
    				<p id="wlpeProfileInfo" class="info">Use this form to approve [+view.username+]'s registration</p>
    			</div>
    
    			<legend>[+view.username+]'s User Profile</legend>
    			
    			<!-- These hidden fields are IMPORTANT! -->
    			<input type="hidden" name="internalKey" value="[+view.internalKey+]" />
    			<input type="hidden" name="username" value="[+view.username+]" />
     <input type="hidden" name="usergroup" value="Subscriber" />
    			
    			<label for="wlpeUserProfileFullName">Full Name
    			<input id="wlpeUserProfileFullName" type="text" name="fullname" value="[+view.fullname+]" />
    			</label>
    
    			<label for="wlpeUserProfileEmail">Email
    			<input id="wlpeUserProfileEmail" type="text" name="email" value="[+view.email+]" />
    			</label>
    
    
    
    		</fieldset>
    		<fieldset id="wlpeUserProfileButtons">
                            <button type="submit" id="wlpeApproveUserButton" name="service" value="approveuser">Approve</button>
    			<button type="submit" id="wlpeProfileDoneButton" name="service" value="cancel">Done</button>
    			<button type="submit" id="wlpeProfileDeleteButton" name="service" value="deleteuserprofile">Delete This Profile</button>
    		</fieldset>
    	</form>
    </div>


    On approval an email is sent out to the Registered user directing them to a Validation Page
    Hello Test2

    To activate your new password click the following link:

    http://www.dementiacarematters.com/index.php?id=117&amp;wlpeID=&amp;service=activate&amp;userid=29&amp;activationkey=QdKzUd7nYm

    If successful you can use the following password to login:

    Password:9S5q6fL6y2

    If you did not request this email then please ignore it.

    Regards,
    Site Administrator


    This is where it falls down - it directs you to the Activation Page I set up http://www.dementiacarematters.com/index.php?id=117

    using this chunk
    [+wlpe.message+]
    <div id="wlpeActivate">
    	<form id="wlpeActivateForm" name="wlpeActivateForm" action="[~[*id*]~]" method="POST">
    		<fieldset id="wlpeActivateFieldset">
    			<input type="hidden" name="userid" value="[+request.userid+]" />
    			<input type="hidden" name="activationkey" value="[+request.activationkey+]" />
    			
    			<label for="wlpeActivationPassword">Activation password
    			<input type="text" id="wlpeActivationPassword" name="activationpassword" />
    			</label>
    			<label for="wlpeNewPassword">New password
    			<input type="password" id="wlpeNewPassword" name="newpassword" />
    
    			</label>
    			<label for="wlpeNewPasswordConfirm">New password (Confirm)
    			<input type="password" id="wlpeNewPasswordConfirm" name="newpassword.confirm" />
    			</label>
    			
    		</fieldset>
    		<fieldset id="wlpeActivateButtonFieldset">
    			<button type="submit" id="wlpeActivateButton" name="service" value="activated">Activate</button>
    		</fieldset>
    	</form>
    
    </div>


    But on using the password in the email sent etc and then logging on it does not work.

    However if I click on Forgot Password from the login page as the same user the email I receive directs me to a similar script but this works!

    Hello Test2

    To activate your new password click the following link:

    http://www.dementiacarematters.com/index.php?id=108&wlpeID=&service=activate&userid=29&activationkey=kXLkvgYCrd

    If successful you can use the following password to login:

    Password:Lz79QAvMX6

    If you did not request this email then please ignore it.

    Regards,
    Site Administrator


    So hope this will help others get to where I am and that others can just help me finish it off.
      • 1892
      • 82 Posts
      I had a similar problem when I moved my site from localhost to online, but I had to do a little digging to remember what I had done!

      Basically when you approve the new user his activation email of the style

      http://www.dementiacarematters.com/index.php?id=117&wlpeID=&service=activate&userid=29&activationkey=QdKzUd7nYm

      Note the &amp; prior to the userid and activationkey. The problem is that when you follow the link
      and then inspect the html in the activation logon box then you’ll find two hidden fields, the values for userid and activationkey are blank.
      <input type="hidden" name="userid" value="">
      <input type="hidden" name="activationkey" value="">
      >

      If you edit the link replacing the "&amp;" with "&" you should find on following the link that the userid and activation key now have a value attributed to them. In this case you should see :
      <input type="hidden" name="userid" value="29">
      <input type="hidden" name="activationkey" value="QdKzUd7nYm">

      So the next problem is to get the activation email generated by webloginpe to create a correctly formed link.

      On this bit I was a bit more suck it and see what happens. In the snippet weblogin.class.php at lines 1064 and 1065 are

      $url = $modx->config['server_protocol'].'://'.$_SERVER['SERVER_NAME'].$modx->makeURL($activateId,'',"&service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey);
      //$url = $_SERVER['HTTP_REFERER']."&service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey;


      This is the bit that is creating the activation link after your site name. Not knowing quite why the first $url converted the & to &amp; I did nothing more scientific than comment out the first $url and uncomment the second $url, I also changed the "&service" to "?service". So I ended up with

      //$url = $modx->config['server_protocol'].'://'.$_SERVER['SERVER_NAME'].$modx->makeURL($activateId,'',"&service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey);
      $url = $_SERVER['HTTP_REFERER']."?service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey;


      This got it working for me so I left it at that before I broke it again.

      Sorry I didn’t back to you sooner and I hope this helps.

      Regards

      Adrian Cherry
        • 1892
        • 82 Posts
        Following up my previous posting I thought I’d better dig into why the "&" was getting replaced with "&amp;"

        It seems that it was the makeURL API call that was reformatting the activation string. At the bottom of this function was
                if ($this->config['xhtml_urls']) {
                	return preg_replace("/&(?!amp;)/","&", $host . $virtualDir . $url);
                } else {
                	return $host . $virtualDir . $url;
                }

        So this was where it was getting reformatted. Searching on xhtml_urls revealed a similar problem with the reformatting of &, see this posting http://modxcms.com/forums/index.php?topic=22250.0

        So I’ve used the same fix for webloginpe, this temporarily sets xhtml_urls to false whilst it is creating $url, so I now use in webloginpe.class.php :
        }else{
             $orgxhtmlconfig = $modx->config['xhtml_urls'];
             $modx->config['xhtml_urls'] = false; // turn off xhtml urls
             $url = $modx->config['server_protocol'].'://'.$_SERVER['SERVER_NAME'].$modx->makeURL($activateId,'',"&service=activate&userid=".$this->User['id'].'&activationkey='.$newPasswordKey);
             $modx->config['xhtml_urls'] = $orgxhtmlconfig; // reset to original value
             //$url = $_SERVER['HTTP_REFERER']."?service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey;
        	            }


        I prefer this solution as it activation email points to the correct activateId referenced from webloginpe.

        I hope this helps.

        Adrian Cherry
          • 10529
          • 73 Posts
          Thanks for the response, however after trying your various fixes still no joy!

          First off I looked at the HTML in the activation logon box for the two hidden fields and the values for userid and activationkey were blank.

          Secondly I did what you suggested (think I might have tried this before) and replaced the "&amp;" with "&" - tried again but still no luck.

          I then went on to the more permanent second fix of changing the lines 1064 and 1065 in the snippet weblogin.class.php - but this did not work and the email still came through with the "&amp".

          So third attempt implemented your suggested fix using the code
          else{
               $orgxhtmlconfig = $modx->config['xhtml_urls'];
               $modx->config['xhtml_urls'] = false; // turn off xhtml urls
               $url = $modx->config['server_protocol'].'://'.$_SERVER['SERVER_NAME'].$modx->makeURL($activateId,'',"&service=activate&userid=".$this->User['id'].'&activationkey='.$newPasswordKey);
               $modx->config['xhtml_urls'] = $orgxhtmlconfig; // reset to original value
               //$url = $_SERVER['HTTP_REFERER']."?service=activate&userid=".$this->User['id']."&activationkey=".$newPasswordKey;
          	            }


          This time the email came in minus "&amp" thought I was there - on clicking the link however and viewing the html source code the hidden fields were still blank - how frustrating!

          I then did a forgort password and clicked the link in the email (see below)

          http://www.dementiacarematters.com/index.php?id=108&wlpeID=&service=activate&userid=38&activationkey=R7UN6qDuJy

          If successful you can use the following password to login:

          Password:j57bNmTfjG

          and looked at the source code and all the field were there

          <div id="wlpeActivate">
          		<form id="wlpeActivateForm" name="wlpeActivateForm" action="index.php?id=108" method="post">
          			<fieldset id="wlpeActivateFieldset">
          				<input type="hidden" name="userid" value="38" />
          				<input type="hidden" name="activationkey" value="R7UN6qDuJy" />
          				
          				<label for="wlpeActivationPassword">Activation password
          				<input type="text" id="wlpeActivationPassword" name="activationpassword" />
          				</label>
          				<label for="wlpeNewPassword">New password
          				<input type="password" id="wlpeNewPassword" name="newpassword" />
          
          				</label>
          				<label for="wlpeNewPasswordConfirm">New password (Confirm)
          				<input type="password" id="wlpeNewPasswordConfirm" name="newpassword_confirm" />
          				</label>
          				
          			</fieldset>
          			<fieldset id="wlpeActivateButtonFieldset">
          				<button type="submit" id="wlpeActivateButton" name="service" value="activated">Activate</button>
          			</fieldset>
          		</form>
          


          So does that point to something wrong with the Chunk I’m calling on the 117 Activation Page but I can’t see anything wrong with it huh?


          [+wlpe.message+]
          <div id="wlpeActivate">
          	<form id="wlpeActivateForm" name="wlpeActivateForm" action="[~[*id*]~]" method="POST">
          		<fieldset id="wlpeActivateFieldset">
          			<input type="hidden" name="userid" value="[+request.userid+]" />
          			<input type="hidden" name="activationkey" value="[+request.activationkey+]" />
          			
          			<label for="wlpeActivationPassword">Activation password
          			<input type="text" id="wlpeActivationPassword" name="activationpassword" />
          			</label>
          			<label for="wlpeNewPassword">New password
          			<input type="password" id="wlpeNewPassword" name="newpassword" />
          
          			</label>
          			<label for="wlpeNewPasswordConfirm">New password (Confirm)
          			<input type="password" id="wlpeNewPasswordConfirm" name="newpassword.confirm" />
          			</label>
          			
          		</fieldset>
          		<fieldset id="wlpeActivateButtonFieldset">
          			<button type="submit" id="wlpeActivateButton" name="service" value="activated">Activate</button>
          		</fieldset>
          	</form>
          
          </div>


          I’ll try uploading another chunk