Skip to content

Commit

Permalink
MDL-65847 auth_db: user_update() handle errors
Browse files Browse the repository at this point in the history
The external database authentication plugin (auth_db) can update the
external database if mapped fields are set to Update external: On
update.  This change adds error handling in case this update fails.
  • Loading branch information
leonstr committed Aug 3, 2020
1 parent 71f3a7f commit 957baa0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 6 additions & 3 deletions auth/db/auth.php
Expand Up @@ -603,9 +603,12 @@ function user_update($olduser, $newuser) {
}
}
if (!empty($update)) {
$authdb->Execute("UPDATE {$this->config->table}
SET ".implode(',', $update)."
WHERE {$this->config->fielduser}='".$this->ext_addslashes($extusername)."'");
$sql = "UPDATE {$this->config->table}
SET ".implode(',', $update)."
WHERE {$this->config->fielduser} = ?";
if (!$authdb->Execute($sql, array($this->ext_addslashes($extusername)))) {
print_error('auth_dbupdateerror', 'auth_db');
}
}
$authdb->Close();
return true;
Expand Down
1 change: 1 addition & 0 deletions auth/db/lang/en/auth_db.php
Expand Up @@ -74,5 +74,6 @@
$string['auth_dbcannotreadtable'] = 'Cannot read external table.';
$string['auth_dbtableempty'] = 'External table is empty.';
$string['auth_dbcolumnlist'] = 'External table contains the following columns:<br />{$a}';
$string['auth_dbupdateerror'] = 'Error updating external database.';
$string['pluginname'] = 'External database';
$string['privacy:metadata'] = 'The External database authentication plugin does not store any personal data.';

0 comments on commit 957baa0

Please sign in to comment.