-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
54 lines (52 loc) · 1.44 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
session_start();
require_once 'rjwt_mod.php';
if (isset($_SESSION['jwt_token'])) {
if (VerifyJWT($_SESSION['jwt_token'], "./rjwt.ini.php") == true) {
header("Location: ./home.php");
} else {
return false;
}
} else {
echo "Token Invalid<br>";
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>login_lib_test_index</title>
</head>
<body>
<div class="login-form">
<form action="index.php" method="post">
<input type="text" name="username" placeholder="Username">
<br>
<input type="password" name="password" placeholder="Password">
<br>
<button type="submit" name="Submit">Login</button>
</form>
</div>
<?php
if (isset($_POST['Submit'])) {
$alert1 = "<script>alert('Invalid Login Attempt')</script>";
$username = protect($_POST["username"]);
$password = protect($_POST["password"]);
if (!$username || !$password) {
print($alert1);
} else {
$authenticated = rjwtAuth($username, $password, "./rjwt.ini.php");
if ($authenticated === false) {
// false returned on failure
print("<script>alert('Failed Login Attempt')</script>");
} else {
// access request was accepted - client authenticated successfully
echo "Success! Proceeding.\n";
header("Location: ./home.php");
}
}
}
?>
</body>
</html>