Fix #13 where multiple families could have same email address
This commit is contained in:
parent
b838fcace4
commit
e8231f6ac2
22
action.php
22
action.php
@ -39,10 +39,6 @@ switch ($VARS['action']) {
|
|||||||
returnToSender("no_permission");
|
returnToSender("no_permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorBack(string $errormsg) {
|
|
||||||
returnToSender($errormsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
$family = new Family();
|
$family = new Family();
|
||||||
$editing = false;
|
$editing = false;
|
||||||
|
|
||||||
@ -51,6 +47,14 @@ switch ($VARS['action']) {
|
|||||||
$editing = true;
|
$editing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function errorBack(string $errormsg) {
|
||||||
|
global $family, $editing;
|
||||||
|
if ($editing) {
|
||||||
|
returnToSender($errormsg, "&id=" . $family->getID());
|
||||||
|
}
|
||||||
|
returnToSender($errormsg);
|
||||||
|
}
|
||||||
|
|
||||||
$database->action(function($database) {
|
$database->action(function($database) {
|
||||||
global $family, $VARS, $editing;
|
global $family, $VARS, $editing;
|
||||||
|
|
||||||
@ -76,6 +80,16 @@ switch ($VARS['action']) {
|
|||||||
$family->setPhone($VARS['phone']);
|
$family->setPhone($VARS['phone']);
|
||||||
$family->setEmail($VARS['email']);
|
$family->setEmail($VARS['email']);
|
||||||
|
|
||||||
|
if ($editing) {
|
||||||
|
if ($database->has("families", ["AND" => ["email" => $family->getEmail(), "familyid[!]" => $family->getID()]])) {
|
||||||
|
errorBack("That email address is already in use with another family.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($database->has("families", ["email" => $family->getEmail()])) {
|
||||||
|
errorBack("That email address is already in use with another family.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$address = $VARS['streetaddress'];
|
$address = $VARS['streetaddress'];
|
||||||
$city = $VARS['city'];
|
$city = $VARS['city'];
|
||||||
$state = strtoupper($VARS['state']);
|
$state = strtoupper($VARS['state']);
|
||||||
|
@ -21,9 +21,11 @@ if (empty($_POST['agree_terms'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$family = new Family();
|
$family = new Family();
|
||||||
|
$renewal = false;
|
||||||
|
|
||||||
if (!empty($_SESSION['familyid']) && $database->has("families", ['familyid' => $_SESSION['familyid']])) {
|
if (!empty($_SESSION['familyid']) && $database->has("families", ['familyid' => $_SESSION['familyid']])) {
|
||||||
$family = (new Family())->load($_SESSION['familyid']);
|
$family = (new Family())->load($_SESSION['familyid']);
|
||||||
|
$renewal = true;
|
||||||
} else if (!empty($_POST['renewing'])) {
|
} else if (!empty($_POST['renewing'])) {
|
||||||
// Session expired, but we're renewing, so kick them back to verification
|
// Session expired, but we're renewing, so kick them back to verification
|
||||||
header("Location: ../?page=renew&msg=sessionexpired");
|
header("Location: ../?page=renew&msg=sessionexpired");
|
||||||
@ -31,7 +33,7 @@ if (!empty($_SESSION['familyid']) && $database->has("families", ['familyid' => $
|
|||||||
}
|
}
|
||||||
|
|
||||||
$database->action(function($database) {
|
$database->action(function($database) {
|
||||||
global $family;
|
global $family, $renewal;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$lastname = $_POST['familyname'];
|
$lastname = $_POST['familyname'];
|
||||||
@ -55,6 +57,16 @@ $database->action(function($database) {
|
|||||||
$family->setPhone($_POST['phone']);
|
$family->setPhone($_POST['phone']);
|
||||||
$family->setEmail($_POST['email']);
|
$family->setEmail($_POST['email']);
|
||||||
|
|
||||||
|
if ($renewal) {
|
||||||
|
if ($database->has("families", ["AND" => ["email" => $family->getEmail(), "familyid[!]" => $family->getID()]])) {
|
||||||
|
errorBack("That email address is already in use with another family.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($database->has("families", ["email" => $family->getEmail()])) {
|
||||||
|
errorBack("That email address is already in use with another family.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$address = $_POST['streetaddress'];
|
$address = $_POST['streetaddress'];
|
||||||
$city = $_POST['city'];
|
$city = $_POST['city'];
|
||||||
$state = strtoupper($_POST['state']);
|
$state = strtoupper($_POST['state']);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user