1
0
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:
Marco
2017-02-25 17:58:29 +01:00
parent 94eeb9dbe0
commit 9c60acec0d
3 changed files with 12 additions and 2 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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 ]