2022-12-20 21:17:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
checkUsernameFormat($_POST['new-username']);
|
|
|
|
|
2023-03-09 14:23:28 +01:00
|
|
|
if (checkPassword($_SESSION['id'], $_POST['current-password']) !== true)
|
|
|
|
output(403, _('Wrong current password.'));
|
|
|
|
|
2022-12-20 21:17:03 +01:00
|
|
|
$username = hashUsername($_POST['new-username']);
|
|
|
|
|
|
|
|
if (usernameExists($username) !== false)
|
2023-01-21 01:27:52 +01:00
|
|
|
output(403, _('This username is already taken.'));
|
2022-12-20 21:17:03 +01:00
|
|
|
|
|
|
|
DB->prepare('UPDATE users SET username = :username WHERE id = :id')
|
|
|
|
->execute([':username' => $username, ':id' => $_SESSION['id']]);
|
|
|
|
|
2023-01-07 23:11:44 +01:00
|
|
|
setupDisplayUsername($_POST['new-username']);
|
|
|
|
|
|
|
|
redir('auth/username');
|
2022-12-20 21:17:03 +01:00
|
|
|
|
2023-01-21 01:27:52 +01:00
|
|
|
output(200, _('Username updated.'));
|