|
@@ -5,13 +5,15 @@ if (processForm(false)) {
|
|
|
|
|
|
checkUsernameFormat($_POST['username']);
|
|
|
|
|
|
- if (userExist($_POST['username']) !== false)
|
|
|
+ $internal_username = hash('sha256', $_POST['username']);
|
|
|
+
|
|
|
+ if (userExist($internal_username) !== false)
|
|
|
output(403, 'Ce nom de compte est déjà utilisé.');
|
|
|
|
|
|
rateLimit();
|
|
|
|
|
|
insert('users', [
|
|
|
- 'username' => $_POST['username'],
|
|
|
+ 'username' => $internal_username,
|
|
|
'password' => hashPassword($_POST['password']),
|
|
|
'registration_date' => date('Y-m-d H:i:s'),
|
|
|
'bucket_tokens' => 0,
|
|
@@ -21,22 +23,23 @@ if (processForm(false)) {
|
|
|
|
|
|
// Setup SFTP directory
|
|
|
umask(0002);
|
|
|
- if (mkdir(CONF['ht']['ht_path'] . '/' . $_POST['username'], 0775) !== true)
|
|
|
+ if (mkdir(CONF['ht']['ht_path'] . '/' . $internal_username, 0775) !== true)
|
|
|
output(500, 'Can\'t create user directory.');
|
|
|
- exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['chgrp_path'] . ' ' . CONF['ht']['sftpgo_group'] . ' ' . CONF['ht']['ht_path'] . '/' . $_POST['username'] . ' --no-dereference', result_code: $code);
|
|
|
+ exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['chgrp_path'] . ' ' . CONF['ht']['sftpgo_group'] . ' ' . CONF['ht']['ht_path'] . '/' . $internal_username . ' --no-dereference', result_code: $code);
|
|
|
if ($code !== 0)
|
|
|
output(500, 'Can\'t change user directory group.');
|
|
|
|
|
|
// Setup Tor config directory
|
|
|
- if (mkdir(CONF['ht']['tor_config_path'] . '/' . $_POST['username'], 0755) !== true)
|
|
|
+ if (mkdir(CONF['ht']['tor_config_path'] . '/' . $internal_username, 0755) !== true)
|
|
|
output(500, 'Can\'t create Tor config directory.');
|
|
|
|
|
|
// Setup Tor keys directory
|
|
|
- exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['mkdir_path'] . ' --mode=0700 ' . CONF['ht']['tor_keys_path'] . '/' . $_POST['username'], result_code: $code);
|
|
|
+ exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['mkdir_path'] . ' --mode=0700 ' . CONF['ht']['tor_keys_path'] . '/' . $internal_username, result_code: $code);
|
|
|
if ($code !== 0)
|
|
|
output(500, 'Can\'t create Tor keys directory.');
|
|
|
|
|
|
- $_SESSION['username'] = $_POST['username'];
|
|
|
+ $_SESSION['username'] = $internal_username;
|
|
|
+ $_SESSION['display-username'] = htmlspecialchars($_POST['username']);
|
|
|
$_SESSION['type'] = 'testing';
|
|
|
|
|
|
redir();
|
|
@@ -48,18 +51,15 @@ if (processForm(false)) {
|
|
|
|
|
|
<form method="post">
|
|
|
|
|
|
- <details>
|
|
|
- <summary><label for="username">Identifiant</label></summary>
|
|
|
- Uniquement composé de lettres minuscules.
|
|
|
- </details>
|
|
|
- <input id="username" minlength="1" maxlength="64" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>"><br>
|
|
|
+ <label for="username">Identifiant</label>
|
|
|
+ <br>
|
|
|
+ <input id="username" minlength="1" maxlength="1024" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>"><br>
|
|
|
|
|
|
<details>
|
|
|
<summary><label for="password">Clé de passe</label></summary>
|
|
|
- <p>Une clé de passe sécurisée est trop compliquée à deviner pour une attaque qui testerais automatiquement plein de clés de passe tout en connaissant d'autres informations et secrets sur vous.</p>
|
|
|
+ <p>Une clé de passe sécurisée est trop compliquée à deviner pour une attaque qui testerait automatiquement plein de clés de passe tout en connaissant d'autres informations et secrets sur vous.</p>
|
|
|
<p>Minimum 8 caractères si elle contient minuscule, majuscule et chiffre, ou minimum 10 caractères sinon.</p>
|
|
|
</details>
|
|
|
-
|
|
|
<input autocomplete="new-password" id="password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" required="" name="password" type="password" placeholder="<?= PLACEHOLDER_PASSWORD ?>"><br>
|
|
|
|
|
|
<input type="submit">
|