2015-10-29 00:47:40 +01:00
|
|
|
<?php
|
2016-07-04 02:32:34 +02:00
|
|
|
use RedBeanPHP\Facade as RedBean;
|
2015-11-01 22:43:35 +01:00
|
|
|
|
2015-11-03 01:55:59 +01:00
|
|
|
class User extends DataStore {
|
2016-07-04 02:32:34 +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',
|
2016-07-06 01:40:30 +02:00
|
|
|
'verificationToken'
|
2016-01-15 03:45:22 +01:00
|
|
|
);
|
2015-11-01 22:43:35 +01:00
|
|
|
}
|
|
|
|
|
2016-05-15 01:22:46 +02:00
|
|
|
public function getDefaultProps() {
|
2016-07-04 02:32:34 +02:00
|
|
|
return array();
|
2016-01-15 03:45:22 +01:00
|
|
|
}
|
|
|
|
|
2016-07-06 01:40:30 +02:00
|
|
|
public function addTicket(Ticket $ticket) {
|
|
|
|
$this->getBeanInstance()->sharedTicketList[] = $ticket->getBeanInstance();
|
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
|
|
|
}
|
|
|
|
}
|