diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controller/auth.control.php | 10 | ||||
-rw-r--r-- | app/model/auth.mod.php | 34 |
2 files changed, 44 insertions, 0 deletions
diff --git a/app/controller/auth.control.php b/app/controller/auth.control.php index 7fafd11..693d190 100644 --- a/app/controller/auth.control.php +++ b/app/controller/auth.control.php @@ -21,6 +21,10 @@ class Auth extends Controller $this->action_signup($mod); break; + case "signup_submit": + $this->action_signup_submit($mod); + break; + default: $this->action_default($mod); break; @@ -46,6 +50,12 @@ class Auth extends Controller $mod->signup(); include "view/auth/signup.view.php"; } + + function action_signup_submit($mod) + { + $mod->signupSubmit($_REQUEST['input']); + $this->action_signup($mod); + } } ?> 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() . "/"); + } } ?> |