Fixed Login: Redirect to previously visited page when using the dedicated login page, too

Steffen

Well-known member
Affected version
2.0.7
If you login using the dedicated login page (https://xenforo.com/community/login/) instead of using the overlay (for example because pages outside of your forum cannot show such overlays) then XenForo should still try to redirect the user to the previously visited page (and not to the homepage).

The following patch seems to do it. :)

Diff:
diff --git a/src/XF/Pub/Controller/Login.php b/src/XF/Pub/Controller/Login.php
index 4ed720dd8..69359ede0 100644
--- a/src/XF/Pub/Controller/Login.php
+++ b/src/XF/Pub/Controller/Login.php
@@ -22,6 +22,7 @@ class Login extends AbstractController

         $providers = $this->repository('XF:ConnectedAccount')->getUsableProviders(false);
         $viewParams = [
+            'redirect' => $this->getDynamicRedirect(null, true),
             'providers' => $providers
         ];
         return $this->view('XF:Login\Form', 'login', $viewParams);
diff --git a/src/addons/XF/_data/templates.xml b/src/addons/XF/_data/templates.xml
index 002cc75d7..46468ea7d 100644
--- a/src/addons/XF/_data/templates.xml
+++ b/src/addons/XF/_data/templates.xml
@@ -45416,6 +45416,8 @@ body:not(.lg-from-hash) .lg-outer.lg-start-zoom .lg-item.lg-complete .lg-object
                 <xf:checkboxrow>
                     <xf:option name="remember" selected="true">{{ phrase('stay_logged_in') }}</xf:option>
                 </xf:checkboxrow>
+
+                <xf:hiddenval name="_xfRedirect">{$redirect}</xf:hiddenval>
             </div>
             <xf:submitrow icon="login" />
         </div>
 
Back
Top Bottom