'Remember me' on login. Issue #81.

This commit is contained in:
Dmitry Khomutov 2017-08-28 21:23:27 +07:00
commit 07359d82f6
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
8 changed files with 158 additions and 147 deletions

View file

@ -94,7 +94,36 @@ class UserStore extends Store
}
$query = 'SELECT * FROM {{user}} WHERE {{email}} = :value OR {{name}} = :value LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':value', $value);
if ($stmt->execute()) {
if ($data = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return new User($data);
}
}
return null;
}
/**
*
* Get a single User by RememberKey.
*
* @param string $value
*
* @throws HttpException
*
* @return User
*/
public function getByRememberKey($value)
{
if (is_null($value)) {
throw new HttpException('Value passed to ' . __FUNCTION__ . ' cannot be null.');
}
$query = 'SELECT * FROM {{user}} WHERE {{remember_key}} = :value LIMIT 1';
$stmt = Database::getConnection()->prepareCommon($query);
$stmt->bindValue(':value', $value);
if ($stmt->execute()) {
@ -108,6 +137,9 @@ class UserStore extends Store
/**
* Get multiple User by Name.
*
* @throws HttpException
*
* @return array
*/
public function getByName($value, $limit = 1000, $useConnection = 'read')