2 // This file is part of Moodle - https://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <https://www.gnu.org/licenses/>.
20 * Update public key against registered user device.
23 * @copyright Alex Morris <alex.morris@catalyst.net.nz>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
29 * Update the users public key for the specified device and app.
31 * @param string $uuid The device UUID.
32 * @param string $appid The app id, usually something like com.moodle.moodlemobile.
33 * @param string $publickey The app generated public key.
37 public static function update_device_public_key(string $uuid, string $appid, string $publickey): bool {
43 'userid' => $USER->id
,
46 if ($DB->record_exists('user_devices', $params)) {
47 $DB->set_field('user_devices', 'publickey', $publickey, $params);