Forgotten password custom function depending on auth plugin

Forgotten password custom function depending on auth plugin

by Álvaro de Lera -
Number of replies: 3

Hi all!


Im working on a custom plugin for authentication. I did the login and signup custom functions overriding Moodle's. Everything is ok till now.


Now I'd like to override the function core_login_process_password_reset() present in login/lib.php to add a check if the user who asks for new password is using my plugin (get_auth_plugin($user->auth)) or not. If yes, I need to add some custom code.


How should I do this task? Can be that function overriden? Id like to mantain Moodle upgrade capability not changing core code. 


TIA and cheers.

Average of ratings: -
In reply to Álvaro de Lera

Re: Forgotten password custom function depending on auth plugin

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

As far as I can see, there's no easy way to override that function.

You might be able to override it (I haven't tried any of this!) by creating a new theme, changing the renderer for the login page . And making the forgotpasswordurl point to another URL that you control. You can implement your additional logic there for the users of your auth plugin, or redirect regular users to the standard forgot password URL.

As I said, I haven't tried any of this, just read the code that creates the login page (hardcoding the URL for the forget password page).

Saludos.

Iñaki

In reply to Iñaki Arenaza

Re: Forgotten password custom function depending on auth plugin

by Álvaro de Lera -

Hi Iñaki,

Thanks for your help, I will try the way you suggest. It seems better way to do it instead of modifying core functions, i didnt think about it.

I will try it and update the post if it works.

Milesker smile


 

In reply to Álvaro de Lera

Re: Forgotten password custom function depending on auth plugin

by Álvaro de Lera -

Ok, I completed succesfully this task. 

I don't know if I follow the simpliest way but it works, so Im putting here if it can help to anyone:

1. I copied forgot_password.php, forgot_password_form.php and set_password_form.php to my custom auth plugin.

2. Added to forgot_password.php some functions of login/lib.php so I could overwrite making them compatible with upgrades, editing them to my needs.

3. Added my new custom forgot password URL to Moodle auth settings.

4. Checked in my forgot_password.php the auth plugin the user has, and if its not my custom auth plugin I replicate Moodle's default behavior.

Regards.

Average of ratings: Useful (1)