MDL-65847 auth_db: user_update() handle errors

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.
This commit is contained in:
Leon Stringer 2020-08-03 11:51:08 +01:00
parent 07238ca511
commit 5049102eb6
2 changed files with 7 additions and 3 deletions

View File

@ -603,9 +603,12 @@ class auth_plugin_db extends auth_plugin_base {
}
}
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;

View File

@ -74,5 +74,6 @@ $string['auth_dbcannotconnect'] = 'Cannot connect to external database.';
$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.';