-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuth.php
More file actions
42 lines (33 loc) · 1020 Bytes
/
Auth.php
File metadata and controls
42 lines (33 loc) · 1020 Bytes
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
<?php
require_once 'Log.php';
Class Auth
{
public static $password = '$2y$10$SLjwBwdOVvnMgWxvTI4Gb.YVcmDlPTpQystHMO2Kfyi/DS8rgA0Fm';
public static function attempt($username, $password)
{
$log = new Log();
if ($username == 'guest' && (password_verify($password, self::$password))){
$_SESSION['logged_in_user'] = $username;
$log->logInfo("User $username logged in.");
return true;
} else {
$log->logError("User $username failed to log in!");
return false;
};
}
public static function check()
{
return (isset($_SESSION['logged_in_user']));
}
public static function user()
{
return $_SESSION['logged_in_user'];
}
public static function logout()
{
// clear $_SESSION array
session_unset();
// delete session data on the server and send the client a new cookie
session_regenerate_id(true);
}
};