summaryrefslogtreecommitdiffstats
path: root/app/model/auth.mod.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/model/auth.mod.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/model/auth.mod.php b/app/model/auth.mod.php
index 5b655d6..aa0adf3 100644
--- a/app/model/auth.mod.php
+++ b/app/model/auth.mod.php
@@ -2,6 +2,7 @@
require_once "model/common.mod.php";
require_once "class/user.class.php";
+require_once "class/form.class.php";
class AuthModel extends CommonModel
{
@@ -35,6 +36,39 @@ class AuthModel extends CommonModel
function signup()
{
}
+
+ /*
+ * Attempt to register a new account
+ */
+ function signupSubmit($input)
+ {
+ $form = new Form();
+ $form->field_text("username");
+ $form->field_text("password", null, false);
+ $form->field_text("cPassword", null, false);
+
+ if (!$form->populate($input))
+ {
+ $this->logFormErrors($form);
+ return;
+ }
+
+ if ($form->password != $form->cPassword)
+ {
+ $this->logError("Passwords do not match");
+ return;
+ }
+
+ $user = new User();
+
+ if (!$user->createNewUser($form->username, $form->password))
+ {
+ $this->logError("Your requested username is already in use");
+ return;
+ }
+
+ $this->redirectTo($this->ap() . "/");
+ }
}
?>