From 61d1aa04d8d44b17bfe6dace90088669fc6c3df8 Mon Sep 17 00:00:00 2001 From: Kyle McFarland Date: Wed, 31 Jan 2018 00:51:07 -0600 Subject: Initial import * Registration system's almost done * Just part way through implementing tasks So not much done yet, but it's a start. --- register.php | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 register.php (limited to 'register.php') diff --git a/register.php b/register.php new file mode 100644 index 0000000..99cb2d1 --- /dev/null +++ b/register.php @@ -0,0 +1,57 @@ +recaptcha_secret); + $username = $_POST["username"]; + $email = $_POST["email"]; + $password = $_POST["passwd"]; + if (isset($_POST["fullname"])) { + $full_name = $_POST["fullname"]; + } else { + $full_name = null; + } + // TODO: we should really filter/validate g-recaptcha-response (still need to do) + $recaptcha_resp = $_POST["g-recaptcha-response"]; + // XXX: one downside of this is it checks the captcha before validating all the other fields, might want to move captcha validation to register() + $resp = $recaptcha->verify($recaptcha_resp); + $captcha_valid = $resp->isSuccess(); + $reg_successful = false; + if ($captcha_valid) { + try { + // TODO: validate_email (5th arg) + $db->register($username, $email, $password, $full_name, true, $twig); + $reg_successful = true; + $success_alerts[] = 'Registration successful, Click here to return to the webapp'; + } catch (RegistrationError $re) { + $reg_successful = false; + $error_text = $re->reason; + $danger_alerts[] = $error_text; + if ($db->conn->inTransaction()) + $db->conn->rollBack(); + } + } else { + $danger_alerts[] = "Captcha Invalid, please try again."; + } +} + +// TODO: move into a util file +echo $twig->render("register.tmpl", array( + "danger_alerts" => $danger_alerts, + "success_alerts" => $success_alerts, + "sess_info" => $sess_info +)); + +?> -- cgit v1.1