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-07-27 18:58:19 +02:00
|
|
|
return ($user && Hashing::verifyPassword($userPassword, $user->password)) ? $user : new NullDataStore();
|
2016-02-02 22:41:10 +01:00
|
|
|
}
|
|
|
|
|
2016-01-15 03:45:22 +01:00
|
|
|
public static function getProps() {
|
2016-08-04 05:59:04 +02:00
|
|
|
return [
|
2016-01-15 03:45:22 +01:00
|
|
|
'email',
|
2016-05-15 00:08:30 +02:00
|
|
|
'password',
|
|
|
|
'name',
|
2016-08-04 05:59:04 +02:00
|
|
|
'admin',
|
|
|
|
'sharedTicketList',
|
|
|
|
'verificationToken',
|
|
|
|
];
|
2015-11-01 22:43:35 +01:00
|
|
|
}
|
|
|
|
|
2016-05-15 01:22:46 +02:00
|
|
|
public function getDefaultProps() {
|
2016-08-04 05:59:04 +02:00
|
|
|
return [
|
|
|
|
'admin' => 0
|
|
|
|
];
|
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
|
|
|
}
|
|
|
|
}
|