-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuth.php
37 lines (33 loc) · 1.35 KB
/
Auth.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
<?php
require "DBController.php";
class Auth {
function getMemberByUsername($username) {
$db_handle = new DBController();
$query = "Select * from members where member_name = ?";
$result = $db_handle->runQuery($query, 's', array($username));
return $result;
}
function getTokenByUsername($username,$expired) {
$db_handle = new DBController();
$query = "Select * from tbl_token_auth where username = ? and is_expired = ?";
$result = $db_handle->runQuery($query, 'si', array($username, $expired));
return $result;
}
function markAsExpired($tokenId) {
$db_handle = new DBController();
$query = "UPDATE tbl_token_auth SET is_expired = ? WHERE id = ?";
$expired = 1;
$result = $db_handle->update($query, 'ii', array($expired, $tokenId));
return $result;
}
function insertToken($username, $random_password_hash, $random_selector_hash, $expiry_date) {
$db_handle = new DBController();
$query = "INSERT INTO tbl_token_auth (username, password_hash, selector_hash, expiry_date) values (?, ?, ?,?)";
$result = $db_handle->insert($query, 'ssss', array($username, $random_password_hash, $random_selector_hash, $expiry_date));
return $result;
}
function update($query) {
mysqli_query($this->conn,$query);
}
}
?>