From 0025f908f7a4fc195fdccf0879140850f9085033 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Thu, 5 Jan 2012 21:00:13 +0100 Subject: register implemented. --- r7r_repo/main.php | 41 ++++++++++++++++++++++++++++++++++++ r7r_repo/templates/src/register.html | 12 +++++++++++ 2 files changed, 53 insertions(+) create mode 100644 r7r_repo/templates/src/register.html (limited to 'r7r_repo') diff --git a/r7r_repo/main.php b/r7r_repo/main.php index a6e0199..f7a16cf 100644 --- a/r7r_repo/main.php +++ b/r7r_repo/main.php @@ -174,6 +174,47 @@ $url_handlers = array( $ste->vars["success"] = "Logged out successfully."; $url_next = array("_prelude", "index"); }, + "register" => function(&$data, $url_now, &$url_next) + { + global $ste, $user, $settings; + + if($settings["repo_mode"] == "private") + throw new NotFoundError(); + + if($user !== NULL) + { + $url_next = array("index"); + return; + } + + $url_next = array(); + $ste->vars["menu"] = "register"; + $ste->vars["title"] = "Register"; + + if(isset($_POST["register"])) + { + if(empty($_POST["username"]) or empty($_POST["password"])) + $ste->vars["error"] = "Formular not filled out."; + else + { + try + { + $u = User::by_name($_POST["username"]); + $ste->vars["error"] = "Username already exists."; + } + catch(DoesNotExistError $e) + { + $u = User::create($_POST["username"]); + $u->isadmin = False; + $u->pwhash = PasswordHash::create($_POST["password"]); + $u->save(); + $ste->vars["success"] = "Account successfully created. You can now log in."; + } + } + } + + echo $ste->exectemplate("register.html"); + }, "setup" => function(&$data, $url_now, &$url_next) { global $settings, $ste; diff --git a/r7r_repo/templates/src/register.html b/r7r_repo/templates/src/register.html new file mode 100644 index 0000000..5d89a71 --- /dev/null +++ b/r7r_repo/templates/src/register.html @@ -0,0 +1,12 @@ + + + + + +
+

Register for a new account

+ Username:
+ Password:
+ +
+
-- cgit v1.2.3-70-g09d2