diff options
author | Malf Furious <m@lfurio.us> | 2016-01-30 21:49:42 -0500 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-01-30 21:49:42 -0500 |
commit | ed1b89d4aa07393d7a9f75c689c4877acfa38826 (patch) | |
tree | ea897da08072d88482f18fba08b998d72c5df636 /app/model/auth.mod.php | |
parent | 2b6afdd9ef767e1e84c4751c72da6be13d9b4402 (diff) | |
download | scrott-ed1b89d4aa07393d7a9f75c689c4877acfa38826.tar.gz scrott-ed1b89d4aa07393d7a9f75c689c4877acfa38826.zip |
Implement signup_submit action on Auth MVC
Submissions to the Auth signup page are now fully handled by either creating a new account (User object in the system) or posting an error message to the page (Auth model)
Diffstat (limited to '')
-rw-r--r-- | app/model/auth.mod.php | 34 |
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() . "/"); + } } ?> |