part of #34: store last openid and pre-fill URL field
authorChristian Weiske <cweiske@cweiske.de>
Mon, 29 Oct 2012 20:09:22 +0000 (21:09 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Mon, 29 Oct 2012 20:09:22 +0000 (21:09 +0100)
data/templates/login.htm
www/login.php

index a825023..08953c8 100644 (file)
@@ -21,7 +21,7 @@
     </div>
     <div id="openid_input_area">
       <p>or enter your OpenID URL.</p>
-      <input id="openid_url" type="text" name="openid_url" value="http://" />
+      <input id="openid_url" type="text" name="openid_url" value="{{openid}}" />
       <input class="btn" id="openid_submit" type="submit" value="Sign in" />
     </div>
   </div>
index fbd337d..fb396b9 100644 (file)
@@ -11,7 +11,13 @@ if (isset($_REQUEST['logout'])) {
 }
 
 if (!count($_GET) && !count($_POST)) {
-    render('login');
+    render(
+        'login',
+        array(
+            'openid' => isset($_COOKIE['lastopenid'])
+                ? $_COOKIE['lastopenid'] : 'http://'
+        )
+    );
     exit();
 }
 
@@ -150,6 +156,8 @@ $name = isset($openid['openid.ax.value.fullname'])
 $_SESSION['name'] = isset($name) ? $name : $_SERVER['REMOTE_ADDR'];
 $_SESSION['identity'] = $openid['openid.identity'];
 
+setcookie('lastopenid', $_SESSION['identity'], time() + 84600 * 60, '/login');
+
 if (isset($_SESSION['REQUEST_URI'])) {
     $redirect = Tools::fullUrl($_SESSION['REQUEST_URI']);
 } else {