从外部网站验证Moodle用户

I have been building a mobile-web-app in HTML5/JQuery and as part of this app I need to require users to log in to Moodle on the app.

Unfortunately I have no idea how to do this.

I'm not sure if I can create a log in form on my App that will check User details with moodle, or if I need to redirect to moodle and get a response from there.

There are a lot of vague, confusing questions about this, so I'm going to be as clear as I can about what the app should do.

user opens App A

App A asks the user to use their moodle details to log in

Moodle tells App if log in was successful

App A either displays an error, or allows user access to the app.

If somebody could help me out here I would really appreciate it.

You can use moodle auth plugins for enabling SSO.

If you are hosting moodle on the same domain, cookies can be shared between App A and moodle and you can use the shared cookies while validating in moodle auth plugin.

And if domains are different, you would need to pass cookie (e.g. sess_uuid) in query parameter and grep it in your auth plugin and use it to validate against App A database (may be using REST call) and if cookies is valid, you can lookup for the user (identified by details provided in cookie validation call) in moodle. If user exists in moodle, you just need to set the global variable $user in the plugin and if user is not present in moodle, depending on you requirement, you can either create new user or do not set user in the plugin which would eventually cause login error.