I've made anUpdate on a new attempt to examine the source code of the Moodle app, but navigating through their codebase has proven to be quite challenging and chaotic, making it difficult to grasp:
login() {
const moodleEndpoint = 'https://mysite/webservice/rest/server.php';
const webServiceToken = 'your_web_service_token';
const params = {
wstoken: webServiceToken,
wsfunction: 'core_user_login',
moodlewsrestformat: 'json',
username: this.username,
password: this.password,
};
this.http.get(moodleEndpoint, { params }).subscribe(
(response: any) => {
if (response.errorcode) {
console.log('Login failed. Error: ' + response.errorcode);
} else {
// Successful login
console.log('Login successful');
// You can navigate to another page or perform other actions here
this.navCtrl.navigateForward('/home/report-page');
}
},
(error) => {
console.error('Login failed. Error: ', error);
}
);
}
}
I'm not too sure what mooodle webservice I would use tho.