ADD: Allow editing of user session data
authorJustin J. Novack <jnovack@gmail.com>
Sun, 16 Sep 2012 15:58:51 +0000 (11:58 -0400)
committerJustin J. Novack <jnovack@gmail.com>
Sun, 16 Sep 2012 15:58:51 +0000 (11:58 -0400)
data/templates/base.htm
data/templates/user.htm [new file with mode: 0644]
www/.htaccess
www/user.php [new file with mode: 0644]

index 8192b6b..ec2b746 100644 (file)
@@ -27,7 +27,7 @@
       </li>
       {% if identity %}
       <li>
-       <a href="#">{{name}} ({{email}})</a>
+       <a href="/user">{{name}} ({{email}})</a>
       </li>
       <li>
        <a href="/auth?logout">Logout</a>
@@ -65,4 +65,4 @@
   </div>
 
  </body>
-</html>
\ No newline at end of file
+</html>
diff --git a/data/templates/user.htm b/data/templates/user.htm
new file mode 100644 (file)
index 0000000..c8ef387
--- /dev/null
@@ -0,0 +1,15 @@
+{% extends "base.htm" %}
+{% block title %}User Preferences{% endblock %}
+
+{% block content %}
+
+<form method="post" action="/user" id="user_form">
+<fieldset>
+  <legend>User Profile</legend>
+   <p>Please update your git preferences for <code>{{ identity }}</code></p>
+   <label for='name'>Name:</label><input class="" id="name" type="text" name="name" width="35" value="{{ name }}"><br/>
+   <label for='email'>Email:</label><input class="" id="email" type="text" name="email" width="35" value="{{ email }}"><br/>
+   <input class="btn" id="submit" type="submit" value="Update">
+</fieldset>
+</form>
+{% endblock %}
index fd2963b..c1d339d 100644 (file)
@@ -23,3 +23,4 @@ RewriteRule ^search/([0-9]+)$ /search.php?page=$1
 RewriteRule ^auth$ /auth.php
 RewriteRule ^login$ /login.php
 RewriteRule ^forbidden$ /forbidden.php
+RewriteRule ^user$ /user.php
diff --git a/www/user.php b/www/user.php
new file mode 100644 (file)
index 0000000..1cc8aeb
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+/**
+ * Edit user information
+ */
+namespace phorkie;
+require_once 'www-header.php';
+if (!isset($_SESSION['identity'])) {
+    require_once 'secure.php';
+}
+
+if (isset($_POST['name'])) {
+    $_SESSION['name'] = substr(filter_var($_POST['name'], FILTER_SANITIZE_STRING), 0, 35);
+}
+
+if (isset($_POST['email'])) {
+    $_SESSION['email'] = substr(filter_var($_POST['email'], FILTER_SANITIZE_EMAIL), 0, 35);
+}
+
+render(
+    'user',
+    array(
+        'identity' => $_SESSION['identity'],
+        'name'     => $_SESSION['name'],
+        'email'    => $_SESSION['email']
+    )
+);
+?>