Hi, is it possible for an external app or site to check to see if the email and password entered by a user matches the user's Moodle login information? Can Moodle return some kind of Boolean yes/no to the external app/site? Thanks.
It's possible. You'd need to write a plugin to do it.
Thanks a lot Howard. Do you know if any similar plugins already exist?
I would probably write this as a local plugin that created a new web service.
So - https://docs.moodle.org/dev/Local_plugins
https://docs.moodle.org/dev/Web_services
Essentially, you're calling the authentication code in Moodle to see if a user is valid. Check out the manual authentication plugin in /auth/manual to see how it does it. The exciting lines are...
if (!$user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id))) {
return false;
}
if (!validate_internal_user_password($user, $password)) {
return false;
}
In your case, you'd be looking up the user record from the email address.
Hi Howard,
Thanks for the response. I have tried creating a simple hello world plugin and install it into my local plugins and given all the necessary permissions and I am having a hard time get it working. I am not sure what I am doing wrong but I followed every instructions as mentioned regarding permissions and user role etc but I still cannot get it working. I tried with hello_world method first so that at least I can check if the web service works or not.
Could you please look at this example and help me find out what is wrong with the code
https://github.com/moodlehq/moodle-local_wstemplate
Thanks, I really appreciate your help on this
Re: Authenticate external app against Moodle login
Hello,
it may be simpler to use token.php (https://github.com/moodle/moodle/blob/master/login/token.php) just like the mobile app does.
Re: Authenticate external app against Moodle login
I just want to validate the username and password using the web service. I don' want to use any other functionalities by moodle. Any suggestion?
Re: Authenticate external app against Moodle login
Hi Daniel,
Thanks for referring to this file on github. Now to call this php file and get the response from it what would I need to do? install a plugin or anything? or just call this url ? enable something from moodle? I am sorry for too many questions as I am just mobile app developer so I have no clue about Moodle things.
I really appreciate your help.
Thanks
Re: Authenticate external app against Moodle login
Hello,
there is a very good example on stack overflow: