Author: david
Date: 2008-11-07 16:24:05 -0800 (Fri, 07 Nov 2008)
New Revision: 1540
Modified:
trunk/qubit/apps/qubit/modules/user/actions/loginAction.class.php
Log:
Fix bug - login page was redirecting user back to login page on successful
login.
Modified: trunk/qubit/apps/qubit/modules/user/actions/loginAction.class.php
===================================================================
--- trunk/qubit/apps/qubit/modules/user/actions/loginAction.class.php
2008-11-07 23:33:50 UTC (rev 1539)
+++ trunk/qubit/apps/qubit/modules/user/actions/loginAction.class.php
2008-11-08 00:24:05 UTC (rev 1540)
@@ -21,15 +21,15 @@
class UserLoginAction extends sfAction
{
-
+
public function execute($request)
{
sfLoader::loadHelpers(array('Url'));
-
+
$this->loginMessage = '';
$this->loginError = '';
$this->loginForm = new UserLoginForm;
-
+
// handle the form submission
if ($request->isMethod('post'))
{
@@ -37,7 +37,7 @@
if ($this->loginForm->isValid())
{
if
($this->getUser()->authenticate($this->loginForm->getValue('email'),
$this->loginForm->getValue('password'), $loginError))
- {
+ {
// redirect to login_route, otherwise redirect to homepage
if ($nextPage = $this->getUser()->getAttribute('login_route'))
{
@@ -55,11 +55,11 @@
}
}
}
-
+
// Set the 'login_route' attribute for redirecting user after
authentication
$this->setLoginRoute($this->getUser());
}
-
+
/**
* Get referring page so we can redirect the user back there after
* successfully authenticating them
@@ -67,24 +67,24 @@
* @param sfUser $user
*/
public function setLoginRoute($user)
- {
- if (!$user->hasAttribute('login_route'))
+ {
+ // if the user selected the log-in page explicitely, send them back to
their referring page
+ if ($this->getRequest()->getPathInfo() == '/user/login')
{
-
- // if the user selected the log-in page explicitely, send them back to
their referring page
- if ($this->getRequest()->getPathInfo() == '/login')
+ // Don't set the login_route to referrer if referrer = current page
(login)
+ if ($this->getRequest()->getReferer() != $this->getRequest()->getUri())
{
$user->setAttribute('login_route', $this->getRequest()->getReferer());
- $this->loginMessage = $this->getContext()->getI18N()->__('log in');
}
-
- // if the user is stopped by the login page on their way to another
page, send them on
- // their way to that page after logging on successfully
- else
- {
- $user->setAttribute('login_route', $this->getRequest()->getUri());
- $this->loginMessage = $this->getContext()->getI18N()->__('please
log-in to access that page');
- }
+ $this->loginMessage = $this->getContext()->getI18N()->__('log in');
}
+
+ // if the user is stopped by the login page on their way to another page,
send them on
+ // their way to that page after logging on successfully
+ else
+ {
+ $user->setAttribute('login_route', $this->getRequest()->getUri());
+ $this->loginMessage = $this->getContext()->getI18N()->__('please log-in
to access that page');
+ }
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---