Make moodle (2.8+) redirect back to external login in case of wrong credentials

Make moodle (2.8+) redirect back to external login in case of wrong credentials

by No name -
Number of replies: 0

Hi,

We need to create an external login and a custom theme for one of our courses. Because of our requirements, we can't change the alternateloginurl setting for the whole system: the platform has it's own theme and custom login.

We know we can include the login form controls inside an external HTML file and login into moodle using the usual approach. In fact, it's working.

We also know that there's no way that Moodle redirect the user back to our external login after signout because it's not configured as alternatelogin, so after logout the user will be redirected to the main login. We don't like it, but it's ok...

The problem

1. When user's try to log in from our external login form (remember, it can't be configured as alternateloginurl)

form inside http://www.afancyexternalloginsite.com:

  <form action="http://www.mymoodlesite.com/index.php" method="post" id="form">
    <input type="text" name="username" />
    <input type="password" name="password" />
    <input type="submit" value="Log in!" />
  </form>

2. ... if he/she writes the wrong credentials then Moodle redirects the user to the main login form (i.e. http://www.mymoodlesite.com/login/index.php) instead redirecting back to our external login with the corresponding ?errorcode=3

3. ... he/she must be redirected to:

http://www.afancyexternalloginsite.com?errorcode=3


Is there any way we can override this behaviour without altering Moodle core?

I hope there's a good solution for this.

Thank you in advance!

PS: sorry for my bad English

Average of ratings: -