aboutsummaryrefslogtreecommitdiff
path: root/r7r_repo
diff options
context:
space:
mode:
authorKevin Chabowski <kevin@kch42.de>2012-01-05 15:21:38 +0100
committerKevin Chabowski <kevin@kch42.de>2012-01-05 15:21:38 +0100
commit5a87705b5142f70e3e13af93a52a9e7f612cf951 (patch)
tree611847524e1691d13df34879cd23ab24298be926 /r7r_repo
parentc4cc87d9d1557ddd4cae4b06b79696712f61a2ad (diff)
downloadr7r-repo-5a87705b5142f70e3e13af93a52a9e7f612cf951.tar.gz
r7r-repo-5a87705b5142f70e3e13af93a52a9e7f612cf951.tar.bz2
r7r-repo-5a87705b5142f70e3e13af93a52a9e7f612cf951.zip
login and logout implemented.
Diffstat (limited to 'r7r_repo')
-rw-r--r--r7r_repo/css/main.css3
-rw-r--r--r7r_repo/main.php49
-rw-r--r--r7r_repo/templates/src/common.html16
-rw-r--r--r7r_repo/templates/src/home.html3
-rw-r--r--r7r_repo/templates/src/master.html1
5 files changed, 70 insertions, 2 deletions
diff --git a/r7r_repo/css/main.css b/r7r_repo/css/main.css
index 7061c42..089ba17 100644
--- a/r7r_repo/css/main.css
+++ b/r7r_repo/css/main.css
@@ -23,12 +23,13 @@ h2 {
height: 10mm;
padding: 0px;
margin: 0px 0px 2mm;
- overflow: hidden;
}
#mainmenu li {
float: left;
margin: 0px 0px 2mm;
+ height: 10mm;
+ overflow: hidden;
}
#mainmenu li a {
diff --git a/r7r_repo/main.php b/r7r_repo/main.php
index af19397..a6e0199 100644
--- a/r7r_repo/main.php
+++ b/r7r_repo/main.php
@@ -99,7 +99,7 @@ $url_handlers = array(
else
$ste->vars["user"] = array(
"logged_in" => True,
- "name" => $user->name,
+ "name" => $user->get_name(),
"admin" => $user->isadmin
);
},
@@ -127,6 +127,53 @@ $url_handlers = array(
echo $ste->exectemplate("home.html");
},
+ "login" => function(&$data, $url_now, &$url_next)
+ {
+ global $ste, $user;
+
+ if(($user === NULL) and isset($_POST["login"]))
+ {
+ try
+ {
+ $user = User::by_name($_POST["username"]);
+ if(PasswordHash::validate($_POST["password"], $user->pwhash))
+ {
+ $ste->vars["success"] = "Logged in successfully.";
+ $_SESSION["r7r_repo_login_name"] = $user->get_name();
+ $url_next = array("_prelude", "index");
+ }
+ else
+ {
+ $user = NULL;
+ $ste->vars["error"] = "Username / Password wrong.";
+ $url_next = array("index");
+ }
+ }
+ catch(DoesNotExistError $e)
+ {
+ $user = NULL;
+ $ste->vars["error"] = "Username / Password wrong.";
+ $url_next = array("index");
+ }
+ }
+ else
+ $url_next = array("index");
+ },
+ "logout" => function(&$data, $url_now, &$url_next)
+ {
+ global $ste, $user;
+
+ if($user === NULL)
+ {
+ $url_next = array("index");
+ return;
+ }
+
+ $user = NULL;
+ unset($_SESSION["r7r_repo_login_name"]);
+ $ste->vars["success"] = "Logged out successfully.";
+ $url_next = array("_prelude", "index");
+ },
"setup" => function(&$data, $url_now, &$url_next)
{
global $settings, $ste;
diff --git a/r7r_repo/templates/src/common.html b/r7r_repo/templates/src/common.html
new file mode 100644
index 0000000..2600e8d
--- /dev/null
+++ b/r7r_repo/templates/src/common.html
@@ -0,0 +1,16 @@
+<ste:mktag name="default_error">
+ <ste:if>
+ $error
+ <ste:then>
+ <div class="error"><ste:escape>$error</ste:escape></div>
+ </ste:then>
+ </ste:if>
+</ste:mktag>
+<ste:mktag name="default_success">
+ <ste:if>
+ $success
+ <ste:then>
+ <div class="success"><ste:escape>$success</ste:escape></div>
+ </ste:then>
+ </ste:if>
+</ste:mktag>
diff --git a/r7r_repo/templates/src/home.html b/r7r_repo/templates/src/home.html
index bf9623a..15d8051 100644
--- a/r7r_repo/templates/src/home.html
+++ b/r7r_repo/templates/src/home.html
@@ -1,5 +1,8 @@
<ste:load name="master.html" />
<ste:block name="content">
+ <ste:default_error />
+ <ste:default_success />
+
<h2>Latest Packages</h2>
<table class="listtab fullwidth">
<thead>
diff --git a/r7r_repo/templates/src/master.html b/r7r_repo/templates/src/master.html
index a2dbd58..9e9b8df 100644
--- a/r7r_repo/templates/src/master.html
+++ b/r7r_repo/templates/src/master.html
@@ -3,6 +3,7 @@
<a href="${rel_path_to_root}${_tag_parameters[path]}"><ste:tagcontent /></a>
</li>
</ste:mktag>
+<ste:load name="common.html" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>