opensupports/server/models/User.php

42 lines
1009 B
PHP
Raw Normal View History

<?php
use RedBeanPHP\Facade as RedBean;
class User extends DataStore {
const TABLE = 'user';
public static function authenticate($userEmail, $userPassword) {
$user = User::getUser($userEmail, 'email');
return ($user && Hashing::verifyPassword($userPassword, $user->password)) ? $user : new NullDataStore();
}
public static function getProps() {
return [
'email',
'password',
'name',
2016-11-30 07:33:46 +01:00
'signupDate',
'tickets',
'sharedTicketList',
'verificationToken'
];
}
2016-05-15 01:22:46 +02:00
public function getDefaultProps() {
return [];
}
public static function getUser($value, $property = 'id') {
return parent::getDataStore($value, $property);
}
public function toArray() {
return [
'email' => $this->email,
'id' => $this->id,
'name' => $this->name,
'verified' => !$this->verificationToken
];
}
}