|
@@ -2,73 +2,60 @@
|
|
|
|
|
|
<p>Déjà un compte ? <a class="auth" href="login">Se connecter</a></p>
|
|
<p>Déjà un compte ? <a class="auth" href="login">Se connecter</a></p>
|
|
|
|
|
|
-<?php
|
|
|
|
-
|
|
|
|
-if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|
|
|
-
|
|
|
|
- checkPasswordFormat($_POST['password']);
|
|
|
|
-
|
|
|
|
- checkUsernameFormat($_POST['username']);
|
|
|
|
-
|
|
|
|
- $userExist = userExist($_POST['username']);
|
|
|
|
|
|
+<form method="post">
|
|
|
|
|
|
- if ($userExist === false) {
|
|
|
|
|
|
+ <details>
|
|
|
|
+ <summary><label for="username">Identifiant</label></summary>
|
|
|
|
+ Uniquement composé de lettres minuscules.
|
|
|
|
+ </details>
|
|
|
|
+ <input id="username" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="<?= PLACEHOLDER_USERNAME ?>"><br>
|
|
|
|
|
|
- // Setup SFTP directory
|
|
|
|
- umask(0002);
|
|
|
|
- if (mkdir(CONF['ht']['ht_path'] . "/" . $_POST['username'], 0775) !== true)
|
|
|
|
- serverError("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", $stdout, $code);
|
|
|
|
- if ($code !== 0)
|
|
|
|
- serverError("Can't change user directory group.");
|
|
|
|
|
|
+ <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>Minimum 8 caractères si elle contient minuscule, majuscule et chiffre, ou minimum 10 caractères sinon.</p>
|
|
|
|
+ </details>
|
|
|
|
|
|
- $password = hashPassword($_POST['password']);
|
|
|
|
|
|
+ <input autocomplete="new-password" id="password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" required="" name="password" type="password" placeholder="<?= PLACEHOLDER_PASSWORD ?>"><br>
|
|
|
|
|
|
- $db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
|
|
+ <input type="submit">
|
|
|
|
+</form>
|
|
|
|
|
|
- $stmt = $db->prepare("INSERT INTO users(username, password, registration_date) VALUES(:username, :password, :registration_date)");
|
|
|
|
|
|
+<?php
|
|
|
|
|
|
- $time = date("Y-m-d H:i:s");
|
|
|
|
|
|
+switchToFormProcess(requireLogin: false);
|
|
|
|
|
|
- $stmt->bindParam(':username', $_POST['username']);
|
|
|
|
- $stmt->bindParam(':password', $password);
|
|
|
|
- $stmt->bindParam(':registration_date', $time);
|
|
|
|
|
|
+checkPasswordFormat($_POST['password']);
|
|
|
|
|
|
- $stmt->execute();
|
|
|
|
|
|
+checkUsernameFormat($_POST['username']);
|
|
|
|
|
|
- $_SESSION['username'] = $_POST['username'];
|
|
|
|
|
|
+if (userExist($_POST['username']) !== false)
|
|
|
|
+ userError("Ce nom de compte est déjà utilisé.");
|
|
|
|
|
|
- header('Location: ' . CONF['common']['prefix'] . '/');
|
|
|
|
- exit;
|
|
|
|
- }
|
|
|
|
|
|
+// Setup SFTP directory
|
|
|
|
+umask(0002);
|
|
|
|
+if (mkdir(CONF['ht']['ht_path'] . "/" . $_POST['username'], 0775) !== true)
|
|
|
|
+ serverError("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", $stdout, $code);
|
|
|
|
+if ($code !== 0)
|
|
|
|
+ serverError("Can't change user directory group.");
|
|
|
|
|
|
-}
|
|
|
|
|
|
+$password = hashPassword($_POST['password']);
|
|
|
|
|
|
-?>
|
|
|
|
|
|
+$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
|
|
-<form method="post">
|
|
|
|
|
|
+$stmt = $db->prepare("INSERT INTO users(username, password, registration_date) VALUES(:username, :password, :registration_date)");
|
|
|
|
|
|
- <details>
|
|
|
|
- <summary><label for="username">Identifiant</label></summary>
|
|
|
|
- Uniquement composé de lettres minuscules.
|
|
|
|
- </details>
|
|
|
|
- <input id="username" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="lain"><span></span><br>
|
|
|
|
|
|
+$time = date("Y-m-d H:i:s");
|
|
|
|
|
|
-<?php
|
|
|
|
-if (isset($userExist) AND $userExist === true) {
|
|
|
|
- echo "<br>Cet identifiant est déjà utilisé. Choisissez-en un autre.";
|
|
|
|
-}
|
|
|
|
-?>
|
|
|
|
|
|
+$stmt->bindParam(':username', $_POST['username']);
|
|
|
|
+$stmt->bindParam(':password', $password);
|
|
|
|
+$stmt->bindParam(':registration_date', $time);
|
|
|
|
|
|
- <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>Minimum 8 caractères si elle contient minuscule, majuscule et chiffre, ou minimum 10 caractères sinon.</p>
|
|
|
|
- </details>
|
|
|
|
|
|
+$stmt->execute();
|
|
|
|
|
|
- <input autocomplete="new-password" id="password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" required="" name="password" type="password" placeholder="************"><span title="Le format nest pas valide"></span><br>
|
|
|
|
|
|
+$_SESSION['username'] = $_POST['username'];
|
|
|
|
|
|
- <input type="submit">
|
|
|
|
-</form>
|
|
|
|
|
|
+header('Location: ' . CONF['common']['prefix'] . '/');
|
|
|
|
|
|
-<?php closeHTML(); ?>
|
|
|
|
|
|
+success("Compte créé.");
|