Jean-Vincent Drean wrote:
On Wed, Sep 24, 2008 at 4:44 PM, Spinring <[email protected]> wrote:
Hello,
I am trying to change the registration page, so that it redirects to the pevious page after you have registered (like after you have logged in)
I know, that login.vm and registerinline.vm are called in global.vm. My first try was to add xredirect=$xwiki.getURLEncoded($logredir) to the $regurl, but it did work.
The register action takes into account the xredirect and do it immediatly. [1] Anyway you could add redirect=$xwiki.getURLEncoded($logredir) to the $regurl (global.vm) And apply this to registerinline.vm
#elseif($reg) + #if($request.redirect) + $response.sendRedirect($request.redirect) + #end #set($xwname = "XWiki.${request.xwikiname}") #info("$msg.get('core.register.successful', [$xwiki.getUserName($xwname), $request.xwikiname])") #end
Anyway I'm not sure that you'll get the expected behavior since the user will be correctly redirected .. without being logged in. To log the user automatically after sign up (+ redirection) you can apply the following patch to registerinline.vm (replace the one above) :
#elseif($reg) + #if($request.redirect) + #set ($xredirect = $xwiki.getURL("XWiki.XWikiLogin", "loginsubmit", "j_username=$!request.xwikiname&j_password=$!request.register_password&xredirect=$!request.redirect")) + $response.sendRedirect($xredirect) + #end #set($xwname = "XWiki.${request.xwikiname}") #info("$msg.get('core.register.successful', [$xwiki.getUserName($xwname), $request.xwikiname])") #end
1) While we are at it, WWYT about adding this in XE 1.7, xwiki devs ? Is it bad to have the password sent over the network once again ?
It is bad to send the password, as it is sent in a GET request, which is a bit less safe than POST, since it is visible in all the logs, and some browsers might store it in the history. How about adding a new checkbox in the registration form, "log me in after registration", which triggers some code in XWiki.java? It can call the PersistentLoginManager with the values it has, and MyPersistenLoginManager (if it is the active LM) will set the right cookies in the response.
2) In this case is there a reason to keep the sendRedirect call in RegisterAction (see [1]) ?
I'd rather do this: Keep the notice message ("successfully registered"), and display a [Return to {title of the initial document}] link. -- Sergiu Dumitriu http://purl.org/net/sergiu/