mirror of
https://github.com/opensupports/opensupports.git
synced 2025-04-08 18:35:06 +02:00
43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?php
|
|
|
|
class User extends DataStore {
|
|
const TABLE = 'users';
|
|
|
|
public static function hashPassword($password) {
|
|
return password_hash($password, PASSWORD_DEFAULT);
|
|
}
|
|
|
|
public static function verifyPassword($password, $hash) {
|
|
return password_verify($password, $hash);
|
|
}
|
|
|
|
public static function authenticate($userEmail, $userPassword) {
|
|
$user = static::getUser($userEmail, 'email');
|
|
|
|
return ($user && static::verifyPassword($userPassword, $user->password)) ? $user : null;
|
|
}
|
|
|
|
public static function getProps() {
|
|
return array(
|
|
'email',
|
|
'password'
|
|
);
|
|
}
|
|
|
|
public function getDefaultProperties() {
|
|
return array();
|
|
}
|
|
|
|
public static function getUser($value, $property = 'id') {
|
|
return parent::getDataStore($value, $property);
|
|
}
|
|
|
|
public static function deleteUser($user) {
|
|
parent::deleteDataStore($user);
|
|
}
|
|
|
|
public function showUserDetails() {
|
|
return $this->_user;
|
|
}
|
|
}
|