summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2016-01-30 21:49:42 -0500
committerMalf Furious <m@lfurio.us>2016-01-30 21:49:42 -0500
commited1b89d4aa07393d7a9f75c689c4877acfa38826 (patch)
treeea897da08072d88482f18fba08b998d72c5df636
parent2b6afdd9ef767e1e84c4751c72da6be13d9b4402 (diff)
downloadscrott-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/controller/auth.control.php10
-rw-r--r--app/model/auth.mod.php34
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() . "/");
+ }
}
?>