From 9c60acec0d01957def4765559bfa8296c64c8a6d Mon Sep 17 00:00:00 2001 From: Marco Date: Sat, 25 Feb 2017 17:58:29 +0100 Subject: [PATCH] Improve code style --- src/Administration.php | 4 +++- src/Auth.php | 6 ++++++ src/UserManager.php | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Administration.php b/src/Administration.php index 12e68c2..8b936cd 100644 --- a/src/Administration.php +++ b/src/Administration.php @@ -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 diff --git a/src/Auth.php b/src/Auth.php index ce84cbf..377c198 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -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) { diff --git a/src/UserManager.php b/src/UserManager.php index 80e7ae7..52819d5 100644 --- a/src/UserManager.php +++ b/src/UserManager.php @@ -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 ]