dce92601ba44c88ce64067ba287e8a66f165742d
[ga4php.git] / authserver / www / index.php
1 <?php 
2
3 require_once("user_actions.php");
4
5 // first check for a token retreival
6 if(isset($_REQUEST["gettoken"])) {
7         $username = $_REQUEST["username"];
8         $otkid = $_REQUEST["otkid"];
9         $users = $myAC->getUsers();
10         $realname = "";
11         $otk = "";
12         foreach($users as $user) {
13                 if($user["username"] == $username) {
14                         $realname = $user["realname"];
15                         $otk = $user["otk"];
16                 }
17         }
18         
19         if($realname == "") $realname = $username;
20         if($otk == "") {
21 ?>
22 <html>
23 Hello <?php echo $realname?>, we're sorry, but your One Time Key has already been picked up or you
24 dont currently have a token. If you believe this in error, please contact the site admin immediately
25 as it could mean your key has been compromised.
26 </html>
27 <?php
28         exit(0); 
29         }
30         
31         if($otk != $otkid) {
32 ?>
33 <html>
34 Hello <?php echo $realname?>, we're sorry, but your One Time Key ID is not
35 the correct one, the URL you have been sent may be in error, please check with the site admin
36 </html>
37 <?php   
38         }
39         
40         // now actually pick up the key
41         if(isset($_REQUEST["ready"])) {
42 ?>
43 <html>
44 Hello <?php echo $realname?>, welcome to the One Time Key retreival site. Here is your<br>
45 One Time Key. Do not save this anywhere as it will compromise your account<br>
46 <li> Point your phones camera at the screen
47 <li> Watch the display until it locks onto the code
48 <li> Once the code has been scanned, the phone should return to the Google Authenticator with a 6 digit number presented, or a "get code" button.<br><hr>
49 <img src="?action=actuallygettoken&username=<?php echo $username?>&otkid=<?php echo $otkid ?>"><br>
50
51 Once you have the key, you may try logging into the user site <a href="index.php">here</a>
52 </html>
53 <?php 
54         } else {
55 ?>
56 <html>
57 Hello <?php echo $realname?>, welcome to the One Time Key retreival site. Before we present<br>
58 your key, you must have your phone ready to accept it as the key will only be presented once.<br>
59 If your phone is not ready to accept the key, the key needs to be regenerated, so only proceed<br>
60 if you phone is on, you have clicked on "scan account barcode" and the phone is ready to<br>
61 scan, please proceed.<br>
62 <br>
63 If you are ready to proceed, click <a href="index.php?gettoken&username=<?php echo $username?>&ready=true&otkid=<?php echo $otkid?>">here</a>.
64 </html>
65 <?php 
66         }
67         exit(0);
68 }
69
70
71 ?>
72 <html>
73 <h1>Welcome to the GAAS User Site</h1>
74 <?php
75 if(isset($_REQUEST["message"])) {
76         echo "<font color=\"green\">".$_REQUEST["message"]."</font>";
77
78 if(isset($_REQUEST["error"])) {
79         echo "<font color=\"red\">".$_REQUEST["error"]."</font>";
80
81
82 if(!$loggedin) {
83 ?>
84 <form method="post" action="?action=login">
85 Username: <input type="text" name="username"><br>
86 Token Code: <input type="text" name="tokencode"><br>
87 <input type="submit" value="Login">
88 </form>
89 </html>
90 <?php
91         exit(0); 
92 } else {
93 ?>
94
95 Hi user
96 </html>
97
98 <hr><a href="?action=logout">Logout</a>
99
100 <?php 
101 }
102 ?>
103