Newer
Older
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
include_once ($_SERVER['DOCUMENT_ROOT'].'/api/lib/database.class.php');
class User
{
private $db;
private $user;
public function __construct($username)
{
$query = "SELECT * FROM `auth` WHERE `username` = '$username' OR `email` = '$username';";
$this->db = database::getconnection();
$result = $this->db->query($query);
if($result->num_rows > 0)
{
$this->user = $result->fetch_assoc();
}
else
{
throw new Exception("User not found");
}
}
public function getUsername(){
return $this->user['username'];
}
public function getPasswordHash(){
return $this->user['password'];
}
public function getEmail(){
return $this->user['email'];
}
public function isActive(){
return $this->user['active'];
}
}