mirror of
https://github.com/moodle/moodle.git
synced 2025-08-09 19:06:41 +02:00
MDL-76722 user: Add new update_user_device_public_key webservice
This commit is contained in:
parent
7c843b380b
commit
9bc236d48d
7 changed files with 381 additions and 0 deletions
25
user/lib.php
25
user/lib.php
|
@ -1363,3 +1363,28 @@ function user_edit_map_field_purpose($userid, $fieldname) {
|
|||
|
||||
return $purpose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the users public key for the specified device and app.
|
||||
*
|
||||
* @param string $uuid The device UUID.
|
||||
* @param string $appid The app id, usually something like com.moodle.moodlemobile.
|
||||
* @param string $publickey The app generated public key.
|
||||
* @return bool
|
||||
* @since Moodle 4.2
|
||||
*/
|
||||
function user_update_device_public_key(string $uuid, string $appid, string $publickey): bool {
|
||||
global $USER, $DB;
|
||||
|
||||
if (!$DB->get_record('user_devices',
|
||||
['uuid' => $uuid, 'appid' => $appid, 'userid' => $USER->id]
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$DB->set_field('user_devices', 'publickey', $publickey,
|
||||
['uuid' => $uuid, 'appid' => $appid, 'userid' => $USER->id]
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue