2022-12-20 21:17:03 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
checkPasswordFormat($_POST['password']);
|
|
|
|
|
|
|
|
checkUsernameFormat($_POST['username']);
|
|
|
|
|
|
|
|
$username = hashUsername($_POST['username']);
|
|
|
|
|
|
|
|
if (usernameExists($username) !== true)
|
2023-01-21 01:27:52 +01:00
|
|
|
output(403, _('This account does not exist.'));
|
2022-12-20 21:17:03 +01:00
|
|
|
|
|
|
|
$id = query('select', 'users', ['username' => $username], 'id')[0];
|
|
|
|
|
|
|
|
if (checkPassword($id, $_POST['password']) !== true)
|
2023-01-21 01:27:52 +01:00
|
|
|
output(403, _('Wrong password.'));
|
2022-12-20 21:17:03 +01:00
|
|
|
|
|
|
|
if (outdatedPasswordHash($id))
|
|
|
|
changePassword($id, $_POST['password']);
|
|
|
|
|
|
|
|
stopSession();
|
|
|
|
startSession();
|
|
|
|
|
|
|
|
$_SESSION['id'] = $id;
|
|
|
|
$_SESSION['type'] = query('select', 'users', ['id' => $id], 'type')[0];
|
|
|
|
|
2023-01-07 23:11:44 +01:00
|
|
|
setupDisplayUsername($_POST['username']);
|
|
|
|
|
2022-12-20 21:17:03 +01:00
|
|
|
redir();
|