-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuth.php
More file actions
46 lines (35 loc) · 984 Bytes
/
Auth.php
File metadata and controls
46 lines (35 loc) · 984 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
43
44
45
46
<?php
require_once 'Log.php';
class Auth
{
public static $password = '$2y$10$SLjwBwdOVvnMgWxvTI4Gb.YVcmDlPTpQystHMO2Kfyi/DS8rgA0Fm';
public static function attempt($username, $password)
{
var_dump($username, $password);
$log = new Log;
if($username == 'guest' && password_verify($password, self::$password)) {
$_SESSION['logged_in_user']=$username;
$log->info("User $username is logged in.");
return true;
} else{
$log->error("User $username failed to log in.");
return false;
}
}
public static function check()
{
return isset($_SESSION['logged_in_user']) ? true : false;
}
public static function user()
{
return $_SESSION['logged_in_user'];
}
public static function logout()
{
session_unset();
session_destroy();
session_regenerate_id();
}
//review functions
}
?>