mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-04 23:27:28 +02:00
Improve code style
This commit is contained in:
@@ -111,7 +111,9 @@ final class Administration extends UserManager {
|
||||
$this->deleteUsersByColumnValue('id', (int) $userData['id']);
|
||||
}
|
||||
|
||||
protected function throttle($actionType, $customSelector = null) {}
|
||||
protected function throttle($actionType, $customSelector = null) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all existing users where the column with the specified name has the given value
|
||||
|
@@ -296,17 +296,23 @@ final class Auth extends UserManager {
|
||||
}
|
||||
|
||||
// set the cookie with the selector and token
|
||||
|
||||
$cookie = new Cookie(self::COOKIE_NAME_REMEMBER);
|
||||
|
||||
$cookie->setValue($content);
|
||||
$cookie->setExpiryTime($expires);
|
||||
|
||||
if (!empty($params['path'])) {
|
||||
$cookie->setPath($params['path']);
|
||||
}
|
||||
|
||||
if (!empty($params['domain'])) {
|
||||
$cookie->setDomain($params['domain']);
|
||||
}
|
||||
|
||||
$cookie->setHttpOnly($params['httponly']);
|
||||
$cookie->setSecureOnly($params['secure']);
|
||||
|
||||
$result = $cookie->save();
|
||||
|
||||
if ($result === false) {
|
||||
|
@@ -40,6 +40,7 @@ abstract class UserManager {
|
||||
public static function createRandomString($maxLength = 24) {
|
||||
// calculate how many bytes of randomness we need for the specified string length
|
||||
$bytes = floor(intval($maxLength) / 4) * 3;
|
||||
|
||||
// get random data
|
||||
$data = openssl_random_pseudo_bytes($bytes);
|
||||
|
||||
@@ -143,8 +144,8 @@ abstract class UserManager {
|
||||
]
|
||||
);
|
||||
}
|
||||
// if we have a duplicate entry
|
||||
catch (IntegrityConstraintViolationException $e) {
|
||||
// if we have a duplicate entry
|
||||
throw new UserAlreadyExistsException();
|
||||
}
|
||||
catch (Error $e) {
|
||||
@@ -175,6 +176,7 @@ abstract class UserManager {
|
||||
protected function getUserDataByUsername($username, array $requestedColumns) {
|
||||
try {
|
||||
$projection = implode(', ', $requestedColumns);
|
||||
|
||||
$users = $this->db->select(
|
||||
'SELECT ' . $projection . ' FROM users WHERE username = ? LIMIT 0, 2',
|
||||
[ $username ]
|
||||
|
Reference in New Issue
Block a user