aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2015-01-28 18:10:23 +0100
committerChristian Weiske <cweiske@cweiske.de>2015-01-28 18:10:23 +0100
commit19f1b5d2a1730f8e37c8fc5585d30b99e70a8575 (patch)
treeb0c1b4eed49a1c7fe12db01b61bfc3b7b1382005 /src
parent0b8c6658dd1e6782ed3686d91d4263b89cdbb8a7 (diff)
downloadphorkie-19f1b5d2a1730f8e37c8fc5585d30b99e70a8575.tar.gz
phorkie-19f1b5d2a1730f8e37c8fc5585d30b99e70a8575.zip
Automatically login to phorkie
Diffstat (limited to 'src')
-rw-r--r--src/phorkie/Login/AutologinResponse.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/phorkie/Login/AutologinResponse.php b/src/phorkie/Login/AutologinResponse.php
new file mode 100644
index 0000000..9384e3b
--- /dev/null
+++ b/src/phorkie/Login/AutologinResponse.php
@@ -0,0 +1,53 @@
+<?php
+namespace phorkie;
+
+class Login_AutologinResponse
+{
+ /**
+ * 'error' or 'ok'
+ *
+ * @var string
+ */
+ public $status;
+
+ /**
+ * Status message
+ *
+ * @var string
+ */
+ public $message;
+
+ public $name;
+ public $identity;
+
+ public function __construct($status = 'error', $message = null)
+ {
+ $this->status = $status;
+ $this->message = $message;
+ }
+
+ public function send()
+ {
+ if ($this->status == 'error') {
+ //Cookie to prevent trying autologin again and again.
+ // After 1 hour the cookie expires and autologin is tried again.
+ setcookie('tried-autologin', '1', time() + 60 * 60);
+ }
+
+ $data = htmlspecialchars(json_encode($this), ENT_NOQUOTES);
+ header('Content-type: text/html');
+ echo <<<XML
+<html>
+ <head>
+ <title>Autologin response</title>
+ <script type="text/javascript">
+ parent.notifyAutologin($data);
+ </script>
+ </head>
+ <body></body>
+</html>
+
+XML;
+ }
+}
+?>