Fix autologin when creating accounts
This commit is contained in:
parent
aa2c7aa284
commit
12534ee183
2 changed files with 10 additions and 9 deletions
|
@ -12,7 +12,7 @@ if (
|
|||
isset($_COOKIE['niver']) // Resume session
|
||||
OR
|
||||
(SERVICE === "auth" // Create new session
|
||||
AND PAGE === "login"
|
||||
AND (PAGE === "login" OR PAGE === "register")
|
||||
AND isset($_POST['username']))
|
||||
) {
|
||||
session_start([
|
||||
|
|
|
@ -10,15 +10,15 @@ if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|||
|
||||
checkUsernameFormat($_POST['username']);
|
||||
|
||||
$username = $_POST['username'];
|
||||
$userExist = userExist($username);
|
||||
$userExist = userExist($_POST['username']);
|
||||
|
||||
if (!$userExist) {
|
||||
|
||||
// Setup SFTP directory
|
||||
umask(0002);
|
||||
if (mkdir(CONF['ht']['ht_path'] . "/" . $username, 0775) !== true)
|
||||
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'] . "/" . $username, $stdout, $code);
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['chgrp_path'] . " " . CONF['ht']['sftpgo_group'] . " " . CONF['ht']['ht_path'] . "/" . $_POST['username'], $stdout, $code);
|
||||
if ($code !== 0)
|
||||
serverError("Can't change user directory group.");
|
||||
|
||||
|
@ -30,13 +30,14 @@ if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|||
|
||||
$time = date("Y-m-d H:i:s");
|
||||
|
||||
$stmt->bindParam(':username', $username);
|
||||
$stmt->bindParam(':username', $_POST['username']);
|
||||
$stmt->bindParam(':password', $password);
|
||||
$stmt->bindParam(':registration_date', $time);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$_SESSION['username'] = $username;
|
||||
$_SESSION['username'] = $_POST['username'];
|
||||
|
||||
header('Location: ' . CONF['common']['prefix'] . '/');
|
||||
exit;
|
||||
}
|
||||
|
@ -54,10 +55,10 @@ if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|||
<input id="username" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="lain"><span></span><br>
|
||||
</label>
|
||||
<?php
|
||||
if (isset($userExist) AND $userExist == true) {
|
||||
if (isset($userExist) AND $userExist === true) {
|
||||
echo "<br>Cet identifiant est déjà utilisé. Choisissez-en un autre.";
|
||||
}
|
||||
?>
|
||||
?>
|
||||
<label for="password">
|
||||
<details>
|
||||
<summary>Clé de passe</summary>
|
||||
|
|
Loading…
Reference in a new issue