2015-10-29 00:47:40 +01:00
|
|
|
<?php
|
2015-11-01 22:43:35 +01:00
|
|
|
|
2015-11-03 01:55:59 +01:00
|
|
|
class User extends DataStore {
|
2016-05-15 00:08:30 +02:00
|
|
|
const TABLE = 'user';
|
2016-02-02 22:41:10 +01:00
|
|
|
|
|
|
|
public static function authenticate($userEmail, $userPassword) {
|
2016-05-15 00:08:30 +02:00
|
|
|
$user = User::getUser($userEmail, 'email');
|
2016-02-02 22:41:10 +01:00
|
|
|
|
2016-05-15 00:08:30 +02:00
|
|
|
return ($user && Hashing::verifyPassword($userPassword, $user->password)) ? $user : null;
|
2016-02-02 22:41:10 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 03:45:22 +01:00
|
|
|
public static function getProps() {
|
|
|
|
return array(
|
|
|
|
'email',
|
2016-05-15 00:08:30 +02:00
|
|
|
'password',
|
|
|
|
'name',
|
|
|
|
'verificationToken',
|
|
|
|
'ownTickets'
|
2016-01-15 03:45:22 +01:00
|
|
|
);
|
2015-11-01 22:43:35 +01:00
|
|
|
}
|
|
|
|
|
2015-11-03 01:55:59 +01:00
|
|
|
public function getDefaultProperties() {
|
2016-05-15 00:08:30 +02:00
|
|
|
return array(
|
|
|
|
'ownTickets' => []
|
|
|
|
);
|
2016-01-15 03:45:22 +01:00
|
|
|
}
|
|
|
|
|
2016-05-15 00:08:30 +02:00
|
|
|
public function addTicket($ticket) {
|
|
|
|
$this->ownTickets[] = $ticket;
|
2016-01-15 03:45:22 +01:00
|
|
|
}
|
|
|
|
|
2016-05-15 00:08:30 +02:00
|
|
|
public static function getUser($value, $property = 'id') {
|
|
|
|
return parent::getDataStore($value, $property);
|
2015-10-29 00:47:40 +01:00
|
|
|
}
|
|
|
|
}
|