I'm currently using the external DB authentication to let users login into my Moodle 3.9 site. The thing is that I need to do an additional check in the external database in order to allow users to log in, so apart from checking username and password, I need to check the date they registered in that external DB (it's one of the fields in that table).
In theory, it would be as easy as modifying the user_login() function in the auth.php file, it would be a small change, but of course I'm aware that modifying the source code isn't a good idea.
So I would like to know what would be the best approach here.
1. Create a new plugin from scratch that connects to my external database and handles the login flow?
2. Duplicate the external DB authentication plugin and just change the code that I need? If I go that route, what things should I take in consideration to not break thinks up?
3. Any other option that would make more sense in this particular situation?
Thanks so much in advance!