<![CDATA[ How to redirect if login failed? - MODX Community Forums]]> https://forums.modx.com/thread/?thread=96560 <![CDATA[How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522614
I'm having the following issue:

I want to redirect to a specific resource (in my case with ID 3) if the user failed to login.
I'm using the following call:

[[!Login? &preHooks=`preHook.DiscussLogin` &loginResourceId=`20` &loginTpl=`lgnNewFrontTpl` &postHooks=`postHook.DiscussLogin` &redirectToOnFailedAuth=`3` ]]


but nothing happens.

The lgnNewFrontTpl call is the following (if it matters):
<div class="loginForm">
    <div class="loginMessage">[[+errors]]</div>
    <div class="loginFront">
        <form class="loginLoginForm" action="[[~[[*id]]]]" method="post">
            <fieldset>
                <p><a href="[[~6]]">Sign Up</a><a href="[[~11]]">Forgot your password?</a></p>
                <p><input type="text" name="username" id="login-username" placeholder="username"></p>
                <p><input type="password" name="password" id="login-password" placeholder="password"></p>
                <input class="returnUrl" type="hidden" name="returnUrl" value="[[+request_uri]]" />
                [[+login.recaptcha_html]]
                <input class="loginLoginValue" type="hidden" name="service" value="login" />
                <span class="loginLoginButton"><input type="submit" name="Login" value="[[+actionMsg]]"  /></span>
            </fieldset>
        </form>
    </div>
</div>


I think I'm doing something wrong with the &redirectToOnFailedAuth=`3`. There is no info how to use it.
In the Login documentation (http://rtfm.modx.com/extras/revo/login/login.login) is written the following:
redirectToOnFailedAuth (1.6.4-pl & +) redirects to a separate page on failed logins

Did somebody know how to use the &redirectToOnFailedAuth or if there is another way to make this redirection working?

Thank you in advance!]]>
deyand Mar 15, 2015, 04:01 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522614
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-546291
I am using redirectToOnFailedAuth=`11` with the id I want failed logins to redirect to just as the others point out above.]]>
redstormj Nov 09, 2016, 03:54 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-546291
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-541685 Quote from: BobRay at May 18, 2016, 11:11 PM
@SyberKnight -- both of those properties take a Resource ID for their arguments.
Also, &redirectToOnFailedAuth can't be used to redirect to the current page.
The page you redirect to needs to be published and accessible by anonymous users. It probably also needs to be in the main front-end context ('web').

Hi Bob,

thanks for piping in, but these are things i actually DO know (LOL - as opposed to the many many i don't).

i only wrote the above with pound/hash/number symbol instead of the numbers i use because everyone has different numbers. i do have the proper numbers in there for my resource id's.

also note, i'm not trying to redirect to the current page. i have separate "error" pages setup with (hopefully) helpful tips on why the user may have gotten there & how to remedy the issue. and they are published & accessible & front-end'ed.

even still, when i test for the errors, the 404 page always overrides the redirectToOnFailedAuth page.

and as far as the redirectToPrior goes, it just never worked. after login, it would just redirect to the homepage. so i'm using the loginResourceId to make it redirect to the page of my choosing instead.

thanks tho!!!]]>
syberknight May 19, 2016, 01:17 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-541685
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-541650
Also, &redirectToOnFailedAuth can't be used to redirect to the current page.

if ($redirectToOnFailedAuth && $redirectToOnFailedAuth != $this->modx->resource->get('id')) {


The page you redirect to needs to be published and accessible by anonymous users. It probably also needs to be in the main front-end context ('web').]]>
BobRay May 18, 2016, 06:11 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-541650
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-541646 Quote from: deyand at Mar 16, 2015, 06:40 PM
But still wondering why it's not working the standard way with using &redirectToOnFailedAuth.

i'm with ya! i just discovered using "&redirectToOnFailedAuth=`#`" in my login does NOT work either!
and neither does "&redirectToPrior=`#`".

i've searched & read as much as i could find on these 2, but they just simply do not work (for me) on Revo 2.4.3.

any errors in the login that would redirect to another Resource, would always go to my 404 Page Not Found page/resource i have set in the System Settings.

FYI: i'm not necessarily needing a reply; i've done workarounds or alternative methods to accomplish what i need; just piping in to express my agreement of there being a problem.

]]>
syberknight May 18, 2016, 02:49 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-541646
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522726
We found another way to make this happen and it's with using the code from the Discuss login (it's installed also on the site). In the Forum (Discuss) when you enter wrong user or password and login failed it redirects you to the login page.

So just changed line 4 in lgnNewFrintTpl (which is edited lgnLoginTpl chunk) with this :
<form class="loginLoginForm" method="post" action="[[~[[++discuss.login_resource_id]]]]">


In this case you don't need &redirectToOnFailedAuth in your Login snippet tag.
But still wondering why it's not working the standard way with using &redirectToOnFailedAuth.
]]>
deyand Mar 16, 2015, 01:40 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522726
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522655
@BobRay: I've added already that property to my Login snippet tag. You can see it at the end of the Login call above.

@brandonhim: I have to check later in the day if this is going to work and will post the result here.]]>
deyand Mar 16, 2015, 03:06 AM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522655
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522642
[[!Login? &redirectToOnFailedAuth=`12`]]



(Replace 12 with the ID of the page you want to send them to.)]]>
BobRay Mar 15, 2015, 11:38 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522642
<![CDATA[Re: How to redirect if login failed?]]> https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522637
To do this, go to the snippet>properties tab>add property set> then edit your desired properties (don't forget the redirect property).

Adding a property set will prevent the default locked properties from being overwritten when upgrading your plugin.]]>
brandonhim Mar 15, 2015, 10:57 PM https://forums.modx.com/thread/96560/how-to-redirect-if-login-failed#dis-post-522637