|
@@ -6,11 +6,9 @@ if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|
|
|
|
|
antiCSRF();
|
|
|
|
|
|
- if (!checkPasswordFormat($_POST['password']))
|
|
|
- exit("Le format du mot de passe n'est pas valide !");
|
|
|
+ checkPasswordFormat($_POST['password']);
|
|
|
|
|
|
- if (!checkUsernameFormat($_POST['username']))
|
|
|
- exit("Le format du nom du compte n'est pas valide !");
|
|
|
+ checkUsernameFormat($_POST['username']);
|
|
|
|
|
|
$username = $_POST['username'];
|
|
|
$userExist = userExist($username);
|
|
@@ -18,17 +16,17 @@ if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|
|
|
|
|
// Setup SFTP directory
|
|
|
umask(0002);
|
|
|
- if (!mkdir(CONF['ht']['ht_path'] . "/" . $username, 0775))
|
|
|
- exit("ERROR: Can't create directory");
|
|
|
+ if (mkdir(CONF['ht']['ht_path'] . "/" . $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);
|
|
|
if ($code !== 0)
|
|
|
- exit("ERROR: Can't change group");
|
|
|
+ serverError("Can't change user directory group.");
|
|
|
|
|
|
$password = hashPassword($_POST['password']);
|
|
|
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
|
|
- $stmt = $db->prepare("INSERT INTO users(username, password, sftp_enabled, registration_date) VALUES(:username, :password, 0, :registration_date)");
|
|
|
+ $stmt = $db->prepare("INSERT INTO users(username, password, registration_date) VALUES(:username, :password, :registration_date)");
|
|
|
|
|
|
$time = date("Y-m-d H:i:s");
|
|
|
|
|
@@ -39,7 +37,6 @@ if (isset($_POST['username']) AND isset($_POST['password'])) {
|
|
|
$stmt->execute();
|
|
|
|
|
|
$_SESSION['username'] = $username;
|
|
|
- $_SESSION['sftp_enabled'] = false;
|
|
|
header('Location: ' . CONF['common']['prefix'] . '/');
|
|
|
exit;
|
|
|
}
|