Passed
Push — Auth ( c6ffd2...76831f )
by Stone
02:02
created
App/Models/UserModel.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         //check if email is valid for sanity
139 139
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
140 140
             $email = htmlspecialchars($email);
141
-            throw new BlogocException("invalid email " . $email);
141
+            throw new BlogocException("invalid email ".$email);
142 142
         }
143 143
         $sql = $this->baseSqlSelect();
144 144
         $sql .= "
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         $this->bind(':roles_idroles', 1);
187 187
         $this->execute();
188 188
 
189
-        return (int)$this->dbh->lastInsertId();
189
+        return (int) $this->dbh->lastInsertId();
190 190
     }
191 191
 
192 192
     /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         }
218 218
 
219 219
         if ($this->isAccountPasswordBlocked($user)) {
220
-            $response->message = "too many bad passwords, account is blocked for " . Constant::LOCKOUT_MINUTES . " minutes";
220
+            $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes";
221 221
             return $response;
222 222
         }
223 223
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     {
241 241
         if ($token_value) {
242 242
             $this->token = $token_value;
243
-        } else {
243
+        }else {
244 244
             $this->token = bin2hex(random_bytes(16));
245 245
         }
246 246
     }
@@ -301,9 +301,9 @@  discard block
 block discarded – undo
301 301
         $this->execute();
302 302
         $result = $this->fetch();
303 303
 
304
-        if($result)
304
+        if ($result)
305 305
         {
306
-            if(strtotime($result->expires_at) < time())
306
+            if (strtotime($result->expires_at) < time())
307 307
             {
308 308
                 //token has expired
309 309
                 $this->deleteToken($hashedToken);
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -204,9 +204,11 @@
 block discarded – undo
204 204
 
205 205
         $user = $this->getUserDetailsByEmail($email);
206 206
 
207
-        if ($user === false) //no user exists
207
+        if ($user === false) {
208
+            //no user exists
208 209
         {
209 210
             $response->message = "email doesn't exist, register a new account?";
211
+        }
210 212
             return $response;
211 213
         }
212 214
 
Please login to merge, or discard this patch.
App/Controllers/Login.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
         // Create the Transport for mail sending
41 41
         $config = $this->siteConfig->getSiteConfig();
42
-        $this->transport = (new Swift_SmtpTransport($config["SMTP_server"], (int)$config["SMTP_port"]))
42
+        $this->transport = (new Swift_SmtpTransport($config["SMTP_server"], (int) $config["SMTP_port"]))
43 43
             ->setUsername($config["SMTP_user"])
44 44
             ->setPassword($config["SMTP_pass"])
45 45
         ;
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     private function populateUserFromId(int $userId)
80 80
     {
81 81
         $result = $this->userModel->getUserDetailsById($userId);
82
-        $this->populateUser((array)$result);
82
+        $this->populateUser((array) $result);
83 83
     }
84 84
 
85 85
     /**
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function index()
102 102
     {
103
-        if($this->session->isParamSet("user"))
103
+        if ($this->session->isParamSet("user"))
104 104
         {
105 105
             //we are already connected, redirect
106 106
             $this->response->redirect();
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
      */
130 130
     public function register()
131 131
     {
132
-        if($this->session->isParamSet("user"))
132
+        if ($this->session->isParamSet("user"))
133 133
         {
134 134
             //we are already connected, redirect
135 135
             $this->response->redirect();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
             }
190 190
 
191 191
             $authUser = $this->userModel->authenticateUser($email, $password);
192
-            if(!$authUser->success)
192
+            if (!$authUser->success)
193 193
             {
194 194
                 $error = true;
195 195
                 $loginErrors->global = $authUser->message;
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
         //we are authenticated here
209 209
 
210 210
         //populate the user object with returned data
211
-        $this->populateUser((array)$authUser->user);
211
+        $this->populateUser((array) $authUser->user);
212 212
 
213 213
         //if the user wanted to be remembered
214
-        if($rememberMe)
214
+        if ($rememberMe)
215 215
         {
216 216
             $this->userModel->setToken(); //generate a new token
217 217
             $rememberMeToken = $this->userModel->rememberMe($this->user->idusers);
218
-            if($rememberMeToken->success)
218
+            if ($rememberMeToken->success)
219 219
             {
220 220
                 //set cookie
221 221
                 $this->cookie->setCookie("rememberMe", $rememberMeToken->token, $rememberMeToken->expiry_timestamp);
Please login to merge, or discard this patch.
App/Modules/SiteConfig.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $categories = $categoryModel->getCategories();
48 48
         foreach ($categories as $category) {
49 49
             $data += [
50
-                $category->category_name => '/category/posts/' . $category->categories_slug
50
+                $category->category_name => '/category/posts/'.$category->categories_slug
51 51
             ];
52 52
         }
53 53
         return $data;
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
         $session = $this->container->getSession();
61 61
 
62 62
         $userToken = $cookie->getCookie("rememberMe");
63
-        if($userToken)
63
+        if ($userToken)
64 64
         {
65 65
             //we have a rememberMe Hash, login
66 66
             $rememberedLogin = $userModel->findByToken($userToken);
67
-            if($rememberedLogin){
67
+            if ($rememberedLogin) {
68 68
                 //we have a hash, login
69 69
                 $user = $userModel->getUserDetailsById($rememberedLogin->users_idusers);
70 70
                 $session->regenerateSessionId(); //regenerate the ID to avoid session ghosting
Please login to merge, or discard this patch.
Core/Dependency/Cookie.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace Core\Dependency;
4 4
 
5
-class Cookie{
5
+class Cookie {
6 6
 
7 7
     /**
8 8
      * set a cookie
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
      */
22 22
     public function deleteCookie(string $name)
23 23
     {
24
-        setcookie($name, "", time()-3600); //expire the cookie
24
+        setcookie($name, "", time() - 3600); //expire the cookie
25 25
     }
26 26
 
27 27
     /**
Please login to merge, or discard this patch.
Core/Container.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
         $twigOptions = [];
51 51
         if (!Config::DEV_ENVIRONMENT) {
52 52
             $twigOptions = [
53
-                'cache' => dirname(__DIR__) . '/Cache'
53
+                'cache' => dirname(__DIR__).'/Cache'
54 54
             ];
55 55
         }
56
-        $loader = new \Twig_Loader_Filesystem(dirname(__DIR__) . '/App/Views');
56
+        $loader = new \Twig_Loader_Filesystem(dirname(__DIR__).'/App/Views');
57 57
         $twig = new \Twig_Environment($loader, $twigOptions);
58 58
 
59 59
         return $twig;
@@ -68,13 +68,13 @@  discard block
 block discarded – undo
68 68
         if ($this->dbh) {
69 69
             return $this->dbh;
70 70
         }
71
-        $dsn = "mysql:host=" . Config::DB_HOST . ";dbname=" . Config::DB_NAME . ";charset=utf8"; //Creating the Data Source name
71
+        $dsn = "mysql:host=".Config::DB_HOST.";dbname=".Config::DB_NAME.";charset=utf8"; //Creating the Data Source name
72 72
         $opt = [
73 73
             PDO::ATTR_PERSISTENT => true,
74 74
             PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
75 75
             PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ
76 76
         ];
77
-        $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt);;
77
+        $this->dbh = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, $opt); ;
78 78
         return $this->dbh;
79 79
     }
80 80
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function getCookie(): Dependency\Cookie
122 122
     {
123
-        if(!$this->cookie){
123
+        if (!$this->cookie) {
124 124
             $this->cookie = new Cookie();
125 125
         }
126 126
         return $this->cookie;
Please login to merge, or discard this patch.