Hmm. Your question is a bit vague as there are a number of ways you can achieve this.
The most direct approach (in my personal opinion) would be to open an MySQLi connection from the app straight to the Moodle database.
Your pseudo-approach would look something like this:
- User opens app and is prompted to enter username and password
- App records username and password to temporary memory slot
App creates a request to query the database. The query is something within the lines of:
- Does the username exist? If yes, proceed, if no, terminate..
- Does the username have a corresponding password? If yes, proceed, if no, terminate.
- Does the password in the database match the password in the temporary memory slot? If yes, proceed, if no, terminate.
- Authenticate.
Normally, this sort of querying would be done through a server-side lingo such as PHP or Python or whatever, but you can do it with jQuery. Have a look here for method.
You've got to bear in mind that this is not the most secure approach and would not be suitable if you're dealing with sensitive data. This is because the credentials of the db account would have to be stored somewhere in the app, so hypothetically speaking, someone could reverse engineer it to read the credentials.
The data you're checking against is typically held in the mdl_user table. The columns you're looking for are username (varchar(100)) and password (varchar(32)). The passwords are MD5-encrypted.
Tldr: Use jQuery to run MySQL queries against Moodle's database.