Browse Source

Add basic authentication

LaurentTreguier 9 years ago
parent
commit
eccc4d03f5
2 changed files with 34 additions and 5 deletions
  1. 15
    2
      controllers/login.php
  2. 19
    3
      views/login.html.php

+ 15
- 2
controllers/login.php View File

@@ -1,13 +1,26 @@
1 1
 <?php
2 2
 
3
+require_once(dirname(__DIR__)."/controllers/data.php");
4
+require_once(dirname(__DIR__)."/models/data.class.php");
5
+require_once(dirname(__DIR__)."/../DbIds.php");
6
+
3 7
 function login()
4 8
 {
5
-    set("title", "Titre");
9
+    set("title", "Login");
6 10
     
7 11
     return html("login.html.php", "layout.html.php");
8 12
 }
9 13
 
10 14
 function check_login()
11 15
 {
12
-    // TODO
16
+    $identifiers = getAdminIdentifiers();
17
+    
18
+    if($_POST["login"] != $identifiers[0] || $_POST["password"] != $identifiers[1])
19
+    {
20
+        set("title", "Error");
21
+        set("error", true);
22
+    } else
23
+        set("error", false);
24
+    
25
+    return html("login.html.php", "layout.html.php");
13 26
 }

+ 19
- 3
views/login.html.php View File

@@ -1,5 +1,21 @@
1
+<?php
2
+
3
+if(isset($error))
4
+{
5
+    if($error)
6
+        echo "<h1>T'es mauvais Jack</h1>";
7
+    else
8
+    {
9
+?>
10
+
11
+<h1>T'es connecté gros</h1>
12
+
13
+<?php }} else { ?>
14
+
1 15
 <form method="POST">
2
-    <input type="text" placeholder="identifier" />
3
-    <input type="password" placeholder="password" />
4
-    <input type="submit" value="login" />
16
+    <input type="text" placeholder="identifier" name="login"/>
17
+    <input type="password" placeholder="password" name="password"/>
18
+    <input type="submit" value="login"/>
5 19
 </form>
20
+
21
+<?php } ?>