Commit 2c5dbea5 authored by Cecilia Vela Gurovic's avatar Cecilia Vela Gurovic Committed by Gerrit Code Review
Browse files

Merge "Bug 1774554: Throw WebserviceInvalidParameterException error"

parents bc026f1d 7c8f5f5b
......@@ -396,5 +396,5 @@ $string['membersinvalidaction'] = 'invalid action "%s" for user "%s" on group "%
$string['passwordmustbechangedviawebsite'] = 'You need to change your password. Please log in via a web browser in order to update your password.';
$string['featuredisabled'] = 'This web services feature is not enabled. Please contact your site administrator for more information.';
$string['institutionunknown'] = '- unknown -';
$string['unabletodeleteadmin'] = 'Unable to delete user with ID: "%s" as they are an admin';
$string['notuserblog'] = 'The journal is not owned by "%s"';
......@@ -397,6 +397,10 @@ class mahara_user_external extends external_api {
throw new WebserviceInvalidParameterException('delete_users | ' . get_string('accessdeniedforinstuser', 'auth.webservice', $authinstance->institution, $user->id));
}
if ($USER->get('id') == $user->id) {
throw new WebserviceInvalidParameterException('delete_users | ' . get_string('unabletodeleteself1', 'admin'));
}
// only allow deletion of users that have not signed in
if (!empty($user->lastlogin) && !$user->suspendedcusr) {
throw new WebserviceInvalidParameterException('delete_users | ' . get_string('cannotdeleteaccount', 'auth.webservice', $user->id));
......@@ -404,11 +408,9 @@ class mahara_user_external extends external_api {
// must not allow deleting of admins or self!!!
if ($user->admin) {
throw new MaharaException('useradminodelete', 'error');
}
if ($USER->get('id') == $user->id) {
throw new MaharaException('usernotdeletederror', 'error');
throw new WebserviceInvalidParameterException('delete_users | ' . get_string('unabletodeleteadmin', 'auth.webservice', $user->id));
}
delete_user($user->id);
}
db_commit();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment