-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuth.php
More file actions
36 lines (29 loc) · 755 Bytes
/
Auth.php
File metadata and controls
36 lines (29 loc) · 755 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
<?php
class Auth {
public static $username = 'guest';
public static $password = '$2y$10$SLjwBwdOVvnMgWxvTI4Gb.YVcmDlPTpQystHMO2Kfyi/DS8rgA0Fm';
public static function attempt($username, $password)
{
if ($username === NULL or $password === NULL) {
return;
} elseif ($username === self::$username and password_verify($password, self::$password)) {
$_SESSION['LOGGED_IN_USER'] = self::$username;
return true;
} else {
return false;
}
}
public static function check()
{
return (isset($_SESSION['LOGGED_IN_USER']) and $_SESSION['LOGGED_IN_USER'] === self::$username);
}
public static function user()
{
return self::$username;
}
public static function logout()
{
session_unset();
session_regenerate_id(true);
}
}