@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Core\Container; |
6 | 6 | use Core\Model; |
7 | 7 | |
8 | -class Remembered_loginsModel extends Model{ |
|
8 | +class Remembered_loginsModel extends Model { |
|
9 | 9 | |
10 | 10 | private $token; |
11 | 11 | private $rememberedLoginTbl; |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | { |
26 | 26 | if ($token_value) { |
27 | 27 | $this->token = $token_value; |
28 | - } else { |
|
28 | + }else { |
|
29 | 29 | $this->token = bin2hex(random_bytes(16)); |
30 | 30 | } |
31 | 31 | } |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | $this->execute(); |
87 | 87 | $result = $this->fetch(); |
88 | 88 | |
89 | - if($result) |
|
89 | + if ($result) |
|
90 | 90 | { |
91 | - if(strtotime($result->expires_at) < time()) |
|
91 | + if (strtotime($result->expires_at) < time()) |
|
92 | 92 | { |
93 | 93 | //token has expired |
94 | 94 | $this->deleteToken($hashedToken); |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | */ |
149 | 149 | public function cleanUpTokens() |
150 | 150 | { |
151 | - $sql=" |
|
151 | + $sql = " |
|
152 | 152 | DELETE FROM $this->rememberedLoginTbl |
153 | 153 | WHERE expires_at < :time |
154 | 154 | "; |
@@ -138,7 +138,7 @@ discard block |
||
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 |
||
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 |
||
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 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | // Create the Transport for mail sending |
50 | 50 | $config = $this->siteConfig->getSiteConfig(); |
51 | - $this->transport = (new Swift_SmtpTransport($config["SMTP_server"], (int)$config["SMTP_port"])) |
|
51 | + $this->transport = (new Swift_SmtpTransport($config["SMTP_server"], (int) $config["SMTP_port"])) |
|
52 | 52 | ->setUsername($config["SMTP_user"]) |
53 | 53 | ->setPassword($config["SMTP_pass"]) |
54 | 54 | ; |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | private function populateUserFromId(int $userId) |
89 | 89 | { |
90 | 90 | $result = $this->userModel->getUserDetailsById($userId); |
91 | - $this->populateUser((array)$result); |
|
91 | + $this->populateUser((array) $result); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | public function index() |
111 | 111 | { |
112 | - if($this->session->isParamSet("user")) |
|
112 | + if ($this->session->isParamSet("user")) |
|
113 | 113 | { |
114 | 114 | //we are already connected, redirect |
115 | 115 | $this->response->redirect(); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function register() |
140 | 140 | { |
141 | - if($this->session->isParamSet("user")) |
|
141 | + if ($this->session->isParamSet("user")) |
|
142 | 142 | { |
143 | 143 | //we are already connected, redirect |
144 | 144 | $this->response->redirect(); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | $authUser = $this->userModel->authenticateUser($email, $password); |
201 | - if(!$authUser->success) |
|
201 | + if (!$authUser->success) |
|
202 | 202 | { |
203 | 203 | $error = true; |
204 | 204 | $loginErrors->global = $authUser->message; |
@@ -217,14 +217,14 @@ discard block |
||
217 | 217 | //we are authenticated here |
218 | 218 | |
219 | 219 | //populate the user object with returned data |
220 | - $this->populateUser((array)$authUser->user); |
|
220 | + $this->populateUser((array) $authUser->user); |
|
221 | 221 | |
222 | 222 | //if the user wanted to be remembered |
223 | - if($rememberMe) |
|
223 | + if ($rememberMe) |
|
224 | 224 | { |
225 | 225 | $this->rememberedLoginModel->setToken(); //generate a new token |
226 | 226 | $rememberMeToken = $this->rememberedLoginModel->rememberMe($this->user->idusers); |
227 | - if($rememberMeToken->success) |
|
227 | + if ($rememberMeToken->success) |
|
228 | 228 | { |
229 | 229 | //set cookie |
230 | 230 | $this->cookie->setCookie("rememberMe", $rememberMeToken->token, $rememberMeToken->expiry_timestamp); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $categories = $categoryModel->getCategories(); |
49 | 49 | foreach ($categories as $category) { |
50 | 50 | $data += [ |
51 | - $category->category_name => '/category/posts/' . $category->categories_slug |
|
51 | + $category->category_name => '/category/posts/'.$category->categories_slug |
|
52 | 52 | ]; |
53 | 53 | } |
54 | 54 | return $data; |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | $session = $this->container->getSession(); |
67 | 67 | |
68 | 68 | $userToken = $cookie->getCookie("rememberMe"); |
69 | - if($userToken) |
|
69 | + if ($userToken) |
|
70 | 70 | { |
71 | 71 | //we have a rememberMe Hash, login |
72 | 72 | $rememberedLogin = $rememberedLoginModel->findByToken($userToken); |
73 | - if($rememberedLogin){ |
|
73 | + if ($rememberedLogin) { |
|
74 | 74 | //we have a hash, login |
75 | 75 | $user = $userModel->getUserDetailsById($rememberedLogin->users_idusers); |
76 | 76 | $session->regenerateSessionId(); //regenerate the ID to avoid session ghosting |