@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | private function populateUserFromId(int $userId) |
62 | 62 | { |
63 | 63 | $result = $this->userModel->getUserDetailsById($userId); |
64 | - $this->populateUser((array)$result); |
|
64 | + $this->populateUser((array) $result); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | } |
162 | 162 | |
163 | 163 | $authUser = $this->userModel->authenticateUser($email, $password); |
164 | - if(!$authUser->success) |
|
164 | + if (!$authUser->success) |
|
165 | 165 | { |
166 | 166 | $error = true; |
167 | 167 | $loginErrors->global = $authUser->message; |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | //we are authenticated here |
181 | 181 | |
182 | 182 | //populate the user object with returned data |
183 | - $this->populateUser((array)$authUser->user); |
|
183 | + $this->populateUser((array) $authUser->user); |
|
184 | 184 | $this->setUserSession(); |
185 | 185 | |
186 | 186 | //if all is valid, redirect to user admin page |
@@ -157,12 +157,12 @@ |
||
157 | 157 | return $this->getUserDetailsByEmail($email) !== false; |
158 | 158 | } |
159 | 159 | |
160 | - /** |
|
161 | - * register a new user |
|
162 | - * @param \stdClass $userData |
|
163 | - * @return int |
|
164 | - * @throws \Exception |
|
165 | - */ |
|
160 | + /** |
|
161 | + * register a new user |
|
162 | + * @param \stdClass $userData |
|
163 | + * @return int |
|
164 | + * @throws \Exception |
|
165 | + */ |
|
166 | 166 | public function registerUser(\stdClass $userData): int |
167 | 167 | { |
168 | 168 |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | */ |
56 | 56 | private function addToBadLoginTries($user):void |
57 | 57 | { |
58 | - $badLoginTries = $user->bad_login_tries +1; |
|
59 | - $sql =" |
|
58 | + $badLoginTries = $user->bad_login_tries + 1; |
|
59 | + $sql = " |
|
60 | 60 | UPDATE $this->userTbl |
61 | 61 | SET |
62 | 62 | bad_login_time = NOW(), |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function resetBadLogin($user):void |
78 | 78 | { |
79 | - $sql=" |
|
79 | + $sql = " |
|
80 | 80 | UPDATE $this->userTbl |
81 | 81 | SET |
82 | 82 | bad_login_tries = 0 |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | |
90 | 90 | private function isAccountPasswordBlocked($user) |
91 | 91 | { |
92 | - if($user->bad_login_tries < Constant::NUMBER_OF_BAD_PASSWORD_TRIES) { |
|
92 | + if ($user->bad_login_tries < Constant::NUMBER_OF_BAD_PASSWORD_TRIES) { |
|
93 | 93 | //not enough bad tries yet |
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
97 | 97 | $blockTime = strtotime($user->bad_login_time); |
98 | 98 | $currentTime = time(); |
99 | - if($currentTime-$blockTime > Constant::LOCKOUT_MINUTES*60) |
|
99 | + if ($currentTime - $blockTime > Constant::LOCKOUT_MINUTES * 60) |
|
100 | 100 | { |
101 | 101 | //we have outlived the timeout |
102 | 102 | return false; |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | //check if email is valid for sanity |
135 | 135 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { |
136 | 136 | $email = htmlspecialchars($email); |
137 | - throw new BlogocException("invalid email " . $email); |
|
137 | + throw new BlogocException("invalid email ".$email); |
|
138 | 138 | } |
139 | 139 | $sql = $this->baseSqlSelect(); |
140 | 140 | $sql .= " |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $this->bind(':roles_idroles', 1); |
183 | 183 | $this->execute(); |
184 | 184 | |
185 | - return (int)$this->dbh->lastInsertId(); |
|
185 | + return (int) $this->dbh->lastInsertId(); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -200,13 +200,13 @@ discard block |
||
200 | 200 | |
201 | 201 | $user = $this->getUserDetailsByEmail($email); |
202 | 202 | |
203 | - if($user === false) //no user exists |
|
203 | + if ($user === false) //no user exists |
|
204 | 204 | { |
205 | 205 | $response->message = "email doesn't exist, register a new account?"; |
206 | 206 | return $response; |
207 | 207 | } |
208 | 208 | |
209 | - if($this->isAccountPasswordBlocked($user)) |
|
209 | + if ($this->isAccountPasswordBlocked($user)) |
|
210 | 210 | { |
211 | 211 | $response->message = "too many bad passwords, account is blocked for ".Constant::LOCKOUT_MINUTES." minutes"; |
212 | 212 | return $response; |
@@ -200,9 +200,11 @@ |
||
200 | 200 | |
201 | 201 | $user = $this->getUserDetailsByEmail($email); |
202 | 202 | |
203 | - if($user === false) //no user exists |
|
203 | + if($user === false) { |
|
204 | + //no user exists |
|
204 | 205 | { |
205 | 206 | $response->message = "email doesn't exist, register a new account?"; |
207 | + } |
|
206 | 208 | return $response; |
207 | 209 | } |
208 | 210 |
@@ -23,7 +23,7 @@ |
||
23 | 23 | const POSTS_PER_PAGE = 4; |
24 | 24 | const LIST_PER_PAGE = 10; |
25 | 25 | |
26 | - const EXCERPT_WORD_COUNT =50; |
|
26 | + const EXCERPT_WORD_COUNT = 50; |
|
27 | 27 | |
28 | 28 | //login security |
29 | 29 | const NUMBER_OF_BAD_PASSWORD_TRIES = 3; |