Skip to content

Commit

Permalink
Merge branch 'MDL-67804-master' of https://github.com/jleyva/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
sarjona committed Dec 1, 2021
2 parents 284c27c + a5c48fe commit 7fa38ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions webservice/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function authenticate_user($token) {
$event->add_record_snapshot('external_tokens', $token);
$event->set_legacy_logdata(array(SITEID, 'webservice', 'user suspended', '', $user->username));
$event->trigger();
throw new webservice_access_exception('Refused web service access for suspended username: ' . $user->username);
throw new moodle_exception('wsaccessusersuspended', 'moodle', '', $user->username);
}

//check if the auth method is nologin (in this case refuse connection)
Expand All @@ -198,7 +198,7 @@ public function authenticate_user($token) {
$event->add_record_snapshot('external_tokens', $token);
$event->set_legacy_logdata(array(SITEID, 'webservice', 'nologin auth attempt with web service', '', $user->username));
$event->trigger();
throw new webservice_access_exception('Refused web service access for nologin authentication username: ' . $user->username);
throw new moodle_exception('wsaccessusernologin', 'moodle', '', $user->username);
}

//Check if the user password is expired
Expand Down Expand Up @@ -1071,7 +1071,7 @@ protected function authenticate_user() {
$event->set_legacy_logdata(array(SITEID, '', '', '', get_string('wsaccessuserdeleted', 'webservice',
$user->username) . " - ".getremoteaddr(), 0, $user->id));
$event->trigger();
throw new webservice_access_exception('Refused web service access for deleted username: ' . $user->username);
throw new moodle_exception('wsaccessuserdeleted', 'webservice', '', $user->username);
}

//only confirmed user should be able to call web service
Expand All @@ -1095,7 +1095,7 @@ protected function authenticate_user() {
$event->set_legacy_logdata(array(SITEID, '', '', '', get_string('wsaccessusersuspended', 'webservice',
$user->username) . " - ".getremoteaddr(), 0, $user->id));
$event->trigger();
throw new webservice_access_exception('Refused web service access for suspended username: ' . $user->username);
throw new moodle_exception('wsaccessusersuspended', 'webservice', '', $user->username);
}

//retrieve the authentication plugin if no previously done
Expand All @@ -1114,7 +1114,7 @@ protected function authenticate_user() {
$event->set_legacy_logdata(array(SITEID, '', '', '', get_string('wsaccessuserexpired', 'webservice',
$user->username) . " - ".getremoteaddr(), 0, $user->id));
$event->trigger();
throw new webservice_access_exception('Refused web service access for password expired username: ' . $user->username);
throw new moodle_exception('wsaccessuserexpired', 'webservice', '', $user->username);
}
}

Expand All @@ -1127,7 +1127,7 @@ protected function authenticate_user() {
$event->set_legacy_logdata(array(SITEID, '', '', '', get_string('wsaccessusernologin', 'webservice',
$user->username) . " - ".getremoteaddr(), 0, $user->id));
$event->trigger();
throw new webservice_access_exception('Refused web service access for nologin authentication username: ' . $user->username);
throw new moodle_exception('wsaccessusernologin', 'webservice', '', $user->username);
}

// now fake user login, the session is completely empty too
Expand Down
5 changes: 5 additions & 0 deletions webservice/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ information provided here is intended especially for developers.

This information is intended for authors of webservices, not people writing webservice clients.

=== 4.0 ===

* User access related exceptions have been changed to use the moodle_exception class instead of the generic webservice_access_exception,
the main reason for this change is to allow clients to implement some code logic against an access error.

=== 3.11 ===

* The method webservice::get_user_capabilities() is deprecated now without a replacement. It has been used
Expand Down

0 comments on commit 7fa38ba

Please sign in to comment.