mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-05 07:37:25 +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']);
|
$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
|
* 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
|
// set the cookie with the selector and token
|
||||||
|
|
||||||
$cookie = new Cookie(self::COOKIE_NAME_REMEMBER);
|
$cookie = new Cookie(self::COOKIE_NAME_REMEMBER);
|
||||||
|
|
||||||
$cookie->setValue($content);
|
$cookie->setValue($content);
|
||||||
$cookie->setExpiryTime($expires);
|
$cookie->setExpiryTime($expires);
|
||||||
|
|
||||||
if (!empty($params['path'])) {
|
if (!empty($params['path'])) {
|
||||||
$cookie->setPath($params['path']);
|
$cookie->setPath($params['path']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($params['domain'])) {
|
if (!empty($params['domain'])) {
|
||||||
$cookie->setDomain($params['domain']);
|
$cookie->setDomain($params['domain']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$cookie->setHttpOnly($params['httponly']);
|
$cookie->setHttpOnly($params['httponly']);
|
||||||
$cookie->setSecureOnly($params['secure']);
|
$cookie->setSecureOnly($params['secure']);
|
||||||
|
|
||||||
$result = $cookie->save();
|
$result = $cookie->save();
|
||||||
|
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
|
@@ -40,6 +40,7 @@ abstract class UserManager {
|
|||||||
public static function createRandomString($maxLength = 24) {
|
public static function createRandomString($maxLength = 24) {
|
||||||
// calculate how many bytes of randomness we need for the specified string length
|
// calculate how many bytes of randomness we need for the specified string length
|
||||||
$bytes = floor(intval($maxLength) / 4) * 3;
|
$bytes = floor(intval($maxLength) / 4) * 3;
|
||||||
|
|
||||||
// get random data
|
// get random data
|
||||||
$data = openssl_random_pseudo_bytes($bytes);
|
$data = openssl_random_pseudo_bytes($bytes);
|
||||||
|
|
||||||
@@ -143,8 +144,8 @@ abstract class UserManager {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
// if we have a duplicate entry
|
||||||
catch (IntegrityConstraintViolationException $e) {
|
catch (IntegrityConstraintViolationException $e) {
|
||||||
// if we have a duplicate entry
|
|
||||||
throw new UserAlreadyExistsException();
|
throw new UserAlreadyExistsException();
|
||||||
}
|
}
|
||||||
catch (Error $e) {
|
catch (Error $e) {
|
||||||
@@ -175,6 +176,7 @@ abstract class UserManager {
|
|||||||
protected function getUserDataByUsername($username, array $requestedColumns) {
|
protected function getUserDataByUsername($username, array $requestedColumns) {
|
||||||
try {
|
try {
|
||||||
$projection = implode(', ', $requestedColumns);
|
$projection = implode(', ', $requestedColumns);
|
||||||
|
|
||||||
$users = $this->db->select(
|
$users = $this->db->select(
|
||||||
'SELECT ' . $projection . ' FROM users WHERE username = ? LIMIT 0, 2',
|
'SELECT ' . $projection . ' FROM users WHERE username = ? LIMIT 0, 2',
|
||||||
[ $username ]
|
[ $username ]
|
||||||
|
Reference in New Issue
Block a user