Files

41 lines
1.2 KiB
PHP

<?php
/*
* Reflector Dashboard — web front-end for SvxReflector
* Copyright (C) 2026 SA7AUX (Björn)
* SPDX-License-Identifier: AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version. See the LICENSE file for details.
*/
declare(strict_types=1);
require __DIR__ . '/lib.php';
$uuid = require_login();
csrf_check();
$j = json_in();
$allowed = ['firstname','lastname','shortname','email','city','state','country'];
$updates = [];
foreach ($allowed as $f) {
if (isset($j[$f]) && is_string($j[$f])) $updates[$f] = trim($j[$f]);
}
if (empty($updates)) json_out(['ok'=>false,'error'=>'no_fields'], 400);
// Email-uppdatering kräver index-update
if (isset($updates['email'])) {
$old = acct_get($uuid);
$old_em = strtolower(trim($old['email'] ?? ''));
$new_em = norm_email($updates['email']);
$updates['email'] = $new_em;
if ($old_em !== $new_em) {
if ($old_em !== '') redis()->del(email_index_key($old_em));
redis()->set(email_index_key($new_em), $uuid);
}
}
redis()->hMSet(acct_key($uuid), $updates);
json_out(['ok'=>true]);