lost password?

home
•  xaraya +
•  rails
•  django
•  webdev
•  xamp
•  musings

rss
Tag this page
   

ยป Blogs that link here
last modified: Sep 27, 2006
(first posted: Sep 27, 2006)
(6161 Reads)
keywords: registration
Permalink

Hitting "Back" during registration

What the heck is the point of a registration confirm page if when you hit back and then resubmit you get a Forbidden Operation authid error???

The default behavior in Xaraya when registering as a new user, you fill out the registration form, hit submit, see a confirmation screen. If you confirm, all moves forward fine. But there's not a back button, and if you hit the back button on the browser, you get a Forbidden Operation (authid) error message.

Hopefully we'll post a fix and this article will be moot

User Friendly User Error Message

The first thing is to make the error message a lot less offensive. Its not really a user error at all, its Xaraya's security kicking in and kicking you in the butt.

So I edited the Base module's message-usererror.xd, saved it to mytheme/modules/base/message-usererror.xt, adding the following:

<p>I'm sorry, the Back button cannot be used in the current circumstances.</p>
<p>Please restart the operation.</p>
<h3><a hraf="#xarServerGetCurrentURL()#">Continue</a></h3>

Then in the other <div>'s in the template, I add style="display:none" so they are hidden, such as

<div class="xar-mod-body" style="display:none">

This way the actual error information is still there if you need it, just View Source the page.

Save the Registration Input Values in a Session Var

Next, lets remember what the usr has input ,and put the values into a session variable. We do this in the confirmation template, user-confirmregistration.xd, saved to mytheme/modules/registration/user-confirmregistration.xt. All the user input values are already available to the template, so this is easy.

At the top of the template you can add something like

<xar:set name="reginput">array(
'username' => $username,
'realname' => $realname,
'email'=>$email,
'firstname'=>$properties['firstname']->value,
'lastname'=>$properties['lastname']->value )</xar:set>
<xar:set name="asdf">xarSessionSetVar('reginput', $reginput)</xar:set>

Note the last 2 are examples of hooked dynamic data fields.

 

Get the Saved Reg Values if Form is Empty

Finally, we fill in the saved values, if they exist, in the registration form. We do this in the registration form template, user-registerform.xd, saved to mytheme/modules/registration/user-registerform.xt .

Note that there might already be default values for the reg form input fields, if you had tried to submit the form but register.php found validation errors, such as an invalid email address. So we want those returned values to take precedence.

<xar:set name="reginput">xarSessionGetVar('reginput')</xar:set>
<xar:if condition="!empty($reginput)">
<xar:if condition="empty($values['username']) and !empty($reginput['username'])">
<xar:set name="sdf">1;$values['username'] = $reginput['username']</xar:set>
</xar:if>
<xar:if condition="empty($values['realname']) and !empty($reginput['realname'])">
<xar:set name="sdf">1;$values['realname'] = $reginput['realname']</xar:set>
</xar:if>
<xar:if condition="empty($values['email']) and !empty($reginput['email'])">
<xar:set name="sdf">1;$values['email'] = $reginput['email']</xar:set>
</xar:if>
<xar:if condition="empty($values['firstname']) and !empty($reginput['firstname'])">
<xar:set name="sdf">1;$properties['firstname']->value = $reginput['firstname']</xar:set>
</xar:if>
<xar:if condition="empty($values['lastname']) and !empty($reginput['lastname'])">
<xar:set name="sdf">1;$properties['lastname']->value = $reginput['lastname']</xar:set>
</xar:if>
</xar:if>

 

There are no comments attached to this item.

Post a new comment

How many days in a week?

Name :