Merge pull request 'Opt-In & Optimierung für Datenschutz und Nutzungsbedingungen' (#64) from Datenschutz-Nutzungsbedingungen_ueberarbeiten into dev
Reviewed-on: #64 Reviewed-by: niklas.ortmann <ortmann.niklas@yahoo.de>
This commit was merged in pull request #64.
This commit is contained in:
@@ -12,6 +12,7 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$vorname = trim($_POST["vorname"] ?? "");
|
||||
$nachname = trim($_POST["nachname"] ?? "");
|
||||
$plainPassword = $_POST["password"] ?? "";
|
||||
$termsAccepted = $_POST["termsAccepted"] ?? null;
|
||||
|
||||
if (!userEmailValidator($email)) {
|
||||
$error = "Bitte gib eine gültige E-Mail-Adresse ein.";
|
||||
@@ -21,6 +22,8 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$error = "Der Nachname muss 2 bis 20 Zeichen lang sein und darf nur Buchstaben, Umlaute, Leerzeichen und Bindestriche enthalten.";
|
||||
} elseif (!userPasswordValidator($plainPassword)) {
|
||||
$error = "Das Passwort muss 5 bis 12 Zeichen lang sein.";
|
||||
} elseif ($termsAccepted !== "1") {
|
||||
$error = "Bitte akzeptiere die Datenschutzerklärung und die Nutzungsbedingungen.";
|
||||
} else {
|
||||
try {
|
||||
$dao = UserManager::getInstance();
|
||||
@@ -30,23 +33,34 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
$existingUser = $dao->findUser($email);
|
||||
|
||||
if (!is_dir("data/mails") && !mkdir("data/mails", 0777, true)) {
|
||||
throw new RuntimeException("Ordner data/mails konnte nicht erstellt werden.");
|
||||
throw new RuntimeException(
|
||||
"Ordner data/mails konnte nicht erstellt werden."
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_dir("data/pending") && !mkdir("data/pending", 0777, true)) {
|
||||
throw new RuntimeException("Ordner data/pending konnte nicht erstellt werden.");
|
||||
throw new RuntimeException(
|
||||
"Ordner data/pending konnte nicht erstellt werden."
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_writable("data/mails")) {
|
||||
throw new RuntimeException("Ordner data/mails ist nicht beschreibbar.");
|
||||
throw new RuntimeException(
|
||||
"Ordner data/mails ist nicht beschreibbar."
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_writable("data/pending")) {
|
||||
throw new RuntimeException("Ordner data/pending ist nicht beschreibbar.");
|
||||
throw new RuntimeException(
|
||||
"Ordner data/pending ist nicht beschreibbar."
|
||||
);
|
||||
}
|
||||
|
||||
if ($existingUser === null) {
|
||||
$password = password_hash($plainPassword, PASSWORD_DEFAULT);
|
||||
$password = password_hash(
|
||||
$plainPassword,
|
||||
PASSWORD_DEFAULT
|
||||
);
|
||||
|
||||
$pendingData = [
|
||||
"email" => $email,
|
||||
@@ -57,12 +71,18 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
|
||||
file_put_contents(
|
||||
"data/pending/" . $token . ".json",
|
||||
json_encode($pendingData, JSON_PRETTY_PRINT)
|
||||
json_encode(
|
||||
$pendingData,
|
||||
JSON_PRETTY_PRINT
|
||||
)
|
||||
);
|
||||
|
||||
$mailContent = "
|
||||
<h2>Registrierung bestätigen</h2>
|
||||
<p>Bitte ignorieren Sie diese Nachricht, wenn Sie sich nicht registrieren wollten.</p>
|
||||
<p>
|
||||
Bitte ignorieren Sie diese Nachricht,
|
||||
wenn Sie sich nicht registrieren wollten.
|
||||
</p>
|
||||
<p>
|
||||
<a href='index.php?pfad=confirm-register&token=$token'>
|
||||
Registrierung bestätigen
|
||||
@@ -72,7 +92,10 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
} else {
|
||||
$mailContent = "
|
||||
<h2>Registrierung</h2>
|
||||
<p>Bitte ignorieren Sie diese Nachricht, wenn Sie sich nicht registrieren wollten.</p>
|
||||
<p>
|
||||
Bitte ignorieren Sie diese Nachricht,
|
||||
wenn Sie sich nicht registrieren wollten.
|
||||
</p>
|
||||
<p>Sie sind bereits registriert.</p>
|
||||
<p>
|
||||
<a href='index.php?pfad=password-forgotten'>
|
||||
@@ -82,11 +105,17 @@ if ($_SERVER["REQUEST_METHOD"] === "POST") {
|
||||
";
|
||||
}
|
||||
|
||||
file_put_contents("data/mails/" . $token . ".html", $mailContent);
|
||||
file_put_contents(
|
||||
"data/mails/" . $token . ".html",
|
||||
$mailContent
|
||||
);
|
||||
|
||||
// Neutrale Meldung, damit nicht sichtbar wird, ob die E-Mail bereits registriert ist.
|
||||
$success = 'Weitere Infos finden Sie in der Datei
|
||||
<a href="index.php?pfad=show-mail&token=' . htmlspecialchars($token) . '" target="_blank">xy</a>.';
|
||||
// Neutrale Meldung, damit nicht sichtbar wird,
|
||||
// ob die E-Mail bereits registriert ist.
|
||||
$success = 'Weitere Infos finden Sie in der Datei
|
||||
<a href="index.php?pfad=show-mail&token='
|
||||
. htmlspecialchars($token)
|
||||
. '" target="_blank">xy</a>.';
|
||||
|
||||
} catch (Exception $e) {
|
||||
$error = "Die Registrierung konnte nicht verarbeitet werden.";
|
||||
|
||||
Reference in New Issue
Block a user