Update jQuery from 1.12.4 to 3.7.1
[phorkie.git] / src / phorkie / Login / AutologinResponse.php
1 <?php
2 namespace phorkie;
3
4 class Login_AutologinResponse
5 {
6     /**
7      * 'error' or 'ok'
8      *
9      * @var string
10      */
11     public $status;
12
13     /**
14      * Status message
15      *
16      * @var string
17      */
18     public $message;
19
20     public $name;
21     public $identity;
22
23     public function __construct($status = 'error', $message = null)
24     {
25         $this->status  = $status;
26         $this->message = $message;
27     }
28
29     public function send()
30     {
31         if ($this->status == 'error') {
32             //Cookie to prevent trying autologin again and again.
33             // After 1 hour the cookie expires and autologin is tried again.
34             setcookie('tried-autologin', '1', time() + 60 * 60);
35         }
36
37         $data = htmlspecialchars(json_encode($this), ENT_NOQUOTES);
38         header('Content-type: text/html');
39         echo <<<XML
40 <html>
41  <head>
42   <title>Autologin response</title>
43   <script type="text/javascript">
44     parent.notifyAutologin($data);
45   </script>
46  </head>
47  <body></body>
48 </html>
49
50 XML;
51     }
52 }
53 ?>