diff options
author | Kevin Chabowski <kevin@kch42.de> | 2012-01-05 21:00:13 +0100 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2012-01-05 21:00:13 +0100 |
commit | 0025f908f7a4fc195fdccf0879140850f9085033 (patch) | |
tree | d2a3bf073f3a1715f16569ff603833d0b2a596ca /r7r_repo/main.php | |
parent | 5a87705b5142f70e3e13af93a52a9e7f612cf951 (diff) | |
download | r7r-repo-0025f908f7a4fc195fdccf0879140850f9085033.tar.gz r7r-repo-0025f908f7a4fc195fdccf0879140850f9085033.tar.bz2 r7r-repo-0025f908f7a4fc195fdccf0879140850f9085033.zip |
register implemented.
Diffstat (limited to 'r7r_repo/main.php')
-rw-r--r-- | r7r_repo/main.php | 41 |
1 files changed, 41 insertions, 0 deletions
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; |