servnest/pg-act/auth/register.php

36 lines
675 B
PHP

<?php
checkPasswordFormat($_POST['password']);
checkUsernameFormat($_POST['username']);
$username = hashUsername($_POST['username']);
if (usernameExists($username) !== false)
output(403, _('This username is already taken.'));
rateLimit();
$id = hash('sha256', random_bytes(32));
insert('users', [
'id' => $id,
'username' => $username,
'password' => hashPassword($_POST['password']),
'registration_date' => date('Y-m-d H:i:s'),
'bucket_tokens' => 0,
'bucket_last_update' => 0,
'type' => 'testing',
'services' => '',
]);
stopSession();
startSession();
$_SESSION['id'] = $id;
$_SESSION['type'] = 'testing';
setupDisplayUsername($_POST['username']);
redir();