prevent creation of lists with the address of existing accounts and the other way around

This commit is contained in:
hmrhkr committed 2021-11-10 15:55:10 +01:00
1 parent bf56072f20
commit f203bec567
3 files changed
+52 -23

No files matched your search

+10 -3
View File
@@ -65,12 +65,19 @@ function createmailuser($newmailusername, $newmaildomainid, $newmailpw, $newmail
}
if (strlen($newmailpw) >= 8) {
if ($newmailpw == $newmailpwrep) {
// check if an account with same address exists
$abfrage = "SELECT 1 FROM `accounts` WHERE `username` = :newmailusername AND `domain` = :newmaildomain";
$sth = $dbh->prepare($abfrage);
$sth->execute(array(':newmailusername' => $newmailusername, ':newmaildomain' => $newmaildomain));
$result = $sth->fetchAll();
//print_r($result);
if ($result[0][1] !== 1) {
// check if a list with same address exists
$abfrage = "SELECT 1 FROM `aliases` WHERE `source_username` = :source_username AND `source_domain` = :source_domain";
$sth = $dbh->prepare($abfrage);
$sth->execute(array(':source_username' => $newmailusername, ':source_domain' => $newmaildomain));
$result_list = $sth->fetchAll();
if ($result[0][1] !== 1 and $result_list[0][1] !== 1 ) {
$newmailpwhashed = password_hash($newmailpw, PASSWORD_ARGON2I, ['memory_cost' => 32768, 'time_cost' => 4]);
//$createdtimestamp = date("Y-m-d H:i:s");
// if ($config['maildirencryption']) {
@@ -109,7 +116,7 @@ function createmailuser($newmailusername, $newmaildomainid, $newmailpw, $newmail
exit;
} else { // Emailadresse ist bereits registriert
if ($admin == 1) {
header("Location: ../admin.php?fehler=Mail besteht schon");
header("Location: ../admin.php?fehler=Mail oder Liste besteht schon");
exit;
} else {
header("Location: createmailpre.php?mailalreadytaken=1");