@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @return array users as |
38 | 38 | * [['uuid'=>'username']...] |
39 | 39 | */ |
40 | - public function listUsers(Iterator &$iterator=null); |
|
40 | + public function listUsers(Iterator &$iterator = null); |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Find a set of users based on a partial search string |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return array users as |
48 | 48 | * [['uuid'=>'username']...] |
49 | 49 | */ |
50 | - public function searchUsers($search, Iterator &$iterator=null); |
|
50 | + public function searchUsers($search, Iterator &$iterator = null); |
|
51 | 51 | |
52 | 52 | /** |
53 | 53 | * Create a new User |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * calling this must also be a superuser |
60 | 60 | * @return string - the users uuid |
61 | 61 | */ |
62 | - public function addUser($username, $email, $password, $roles=[], $superuser=false); |
|
62 | + public function addUser($username, $email, $password, $roles = [], $superuser = false); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * Get hold of an User given the user uuid |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | /** |
166 | 166 | * @inheritdoc |
167 | 167 | */ |
168 | - public function getHomeUrl($role=null) |
|
168 | + public function getHomeUrl($role = null) |
|
169 | 169 | { |
170 | 170 | $userRoles = $this->getRoles(); |
171 | 171 | $availableRoles = neon('user')->getRoles(true); |
@@ -333,14 +333,14 @@ discard block |
||
333 | 333 | * @see getUserListUncached for details |
334 | 334 | * @return array |
335 | 335 | */ |
336 | - public static function getUserList($query='', $filters=[], $fields=[], $start=0, $length=100) |
|
336 | + public static function getUserList($query = '', $filters = [], $fields = [], $start = 0, $length = 100) |
|
337 | 337 | { |
338 | 338 | // because we need to cache according to the args we cannot store |
339 | 339 | // results in cache rather cacheArray. This is so we can clear cache |
340 | 340 | // appropriately in other calls such as edit and delete. Also user |
341 | 341 | // information should not be available in cached files |
342 | 342 | return neon()->cacheArray->getOrSet( |
343 | - [static::CACHE_KEY_USER_LIST,func_get_args()], |
|
343 | + [static::CACHE_KEY_USER_LIST, func_get_args()], |
|
344 | 344 | function() use ($query, $filters, $fields, $start, $length) { |
345 | 345 | return self::getUserListUncached($query, $filters, $fields, $start, $length); |
346 | 346 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param int $length - the total number of rows to return |
360 | 360 | * @return array |
361 | 361 | */ |
362 | - public static function getUserListUncached($query='',$filters=[], $fields=[], $start=0, $length=100) |
|
362 | + public static function getUserListUncached($query = '', $filters = [], $fields = [], $start = 0, $length = 100) |
|
363 | 363 | { |
364 | 364 | $q = self::find()->select(array_merge(['uuid', 'username', 'email'], $fields)); |
365 | 365 | if ($q !== '') |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | { |
385 | 385 | return collect($userRows)->mapWithKeys(function($row, $key) use($fields) { |
386 | 386 | if (empty($fields)) |
387 | - return [$row['uuid'] => $row['username'] ? $row['username'] . ' - ' . $row['email'] : $row['email']]; |
|
387 | + return [$row['uuid'] => $row['username'] ? $row['username'].' - '.$row['email'] : $row['email']]; |
|
388 | 388 | return [$row['uuid'] => $row]; |
389 | 389 | })->all(); |
390 | 390 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | */ |
505 | 505 | public function generatePasswordResetToken() |
506 | 506 | { |
507 | - $this->password_reset_token = neon()->security->generateRandomString() . '_' . time(); |
|
507 | + $this->password_reset_token = neon()->security->generateRandomString().'_'.time(); |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | /** |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | /** |
622 | 622 | * @inheritDoc |
623 | 623 | */ |
624 | - public function getImageUrl($size=40) |
|
624 | + public function getImageUrl($size = 40) |
|
625 | 625 | { |
626 | 626 | return Html::gravatar($this->email, $size, 'mm', 'g'); |
627 | 627 | } |
@@ -125,8 +125,9 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function getRoles() |
127 | 127 | { |
128 | - if (!isset(static::$_userRoles[$this->id])) |
|
129 | - static::$_userRoles[$this->id] = array_keys(neon()->authManager->getRolesByUser($this->id)); |
|
128 | + if (!isset(static::$_userRoles[$this->id])) { |
|
129 | + static::$_userRoles[$this->id] = array_keys(neon()->authManager->getRolesByUser($this->id)); |
|
130 | + } |
|
130 | 131 | return is_array(static::$_userRoles[$this->id]) ? static::$_userRoles[$this->id] : []; |
131 | 132 | } |
132 | 133 | |
@@ -139,8 +140,9 @@ discard block |
||
139 | 140 | $authManager->revokeAll($this->id); |
140 | 141 | foreach ($roles as $role) { |
141 | 142 | $r = $authManager->getRole($role); |
142 | - if ($r) |
|
143 | - $authManager->assign($r, $this->id); |
|
143 | + if ($r) { |
|
144 | + $authManager->assign($r, $this->id); |
|
145 | + } |
|
144 | 146 | } |
145 | 147 | unset(static::$_userRoles[$this->id]); |
146 | 148 | } |
@@ -172,12 +174,14 @@ discard block |
||
172 | 174 | |
173 | 175 | // searching in a specific role? |
174 | 176 | if (!empty($role)) { |
175 | - if (isset($availableRoles[$role]['homeUrl'])) |
|
176 | - return $availableRoles[$role]['homeUrl']; |
|
177 | + if (isset($availableRoles[$role]['homeUrl'])) { |
|
178 | + return $availableRoles[$role]['homeUrl']; |
|
179 | + } |
|
177 | 180 | } else { // or finding any one? |
178 | 181 | foreach ($userRoles as $role) { |
179 | - if (isset($availableRoles[$role]['homeUrl'])) |
|
180 | - return $availableRoles[$role]['homeUrl']; |
|
182 | + if (isset($availableRoles[$role]['homeUrl'])) { |
|
183 | + return $availableRoles[$role]['homeUrl']; |
|
184 | + } |
|
181 | 185 | |
182 | 186 | } |
183 | 187 | } |
@@ -204,8 +208,9 @@ discard block |
||
204 | 208 | public static function findIdentity($id) |
205 | 209 | { |
206 | 210 | // The id must be a uuid64 |
207 | - if (!Hash::isUuid64($id)) |
|
208 | - return null; |
|
211 | + if (!Hash::isUuid64($id)) { |
|
212 | + return null; |
|
213 | + } |
|
209 | 214 | // The string conversion here is important to ensure the id is correctly quoted as a string |
210 | 215 | // otherwise if the $id is a number it will match uuid's that start with that number! |
211 | 216 | return self::findOne(['uuid' => (string) $id, 'status' => self::STATUS_ACTIVE]); |
@@ -231,8 +236,9 @@ discard block |
||
231 | 236 | public static function findIdentityByInviteToken($token) |
232 | 237 | { |
233 | 238 | $invite = UserInvite::findInviteByInviteToken($token); |
234 | - if (!$invite) |
|
235 | - return null; |
|
239 | + if (!$invite) { |
|
240 | + return null; |
|
241 | + } |
|
236 | 242 | return User::findOne(['uuid' => $invite->user_id, 'status' => [User::STATUS_PENDING]]); |
237 | 243 | } |
238 | 244 | |
@@ -362,10 +368,12 @@ discard block |
||
362 | 368 | public static function getUserListUncached($query='',$filters=[], $fields=[], $start=0, $length=100) |
363 | 369 | { |
364 | 370 | $q = self::find()->select(array_merge(['uuid', 'username', 'email'], $fields)); |
365 | - if ($q !== '') |
|
366 | - $q->where(['or', ['like', 'username', $query], ['like', 'email', $query]]); |
|
367 | - if (!empty($filters)) |
|
368 | - $q->andWhere($filters); |
|
371 | + if ($q !== '') { |
|
372 | + $q->where(['or', ['like', 'username', $query], ['like', 'email', $query]]); |
|
373 | + } |
|
374 | + if (!empty($filters)) { |
|
375 | + $q->andWhere($filters); |
|
376 | + } |
|
369 | 377 | $q->offset($start) |
370 | 378 | ->limit($length) |
371 | 379 | ->orderBy(['username' => SORT_ASC, 'email' => SORT_ASC]) |
@@ -383,8 +391,9 @@ discard block |
||
383 | 391 | public static function formatDataMapItems($userRows, $fields) |
384 | 392 | { |
385 | 393 | return collect($userRows)->mapWithKeys(function($row, $key) use($fields) { |
386 | - if (empty($fields)) |
|
387 | - return [$row['uuid'] => $row['username'] ? $row['username'] . ' - ' . $row['email'] : $row['email']]; |
|
394 | + if (empty($fields)) { |
|
395 | + return [$row['uuid'] => $row['username'] ? $row['username'] . ' - ' . $row['email'] : $row['email']]; |
|
396 | + } |
|
388 | 397 | return [$row['uuid'] => $row]; |
389 | 398 | })->all(); |
390 | 399 | } |
@@ -538,8 +547,9 @@ discard block |
||
538 | 547 | { |
539 | 548 | // remove any caches and authorisations against the user |
540 | 549 | neon()->cacheArray->delete(static::CACHE_KEY_USER_LIST); |
541 | - if ($this->id) |
|
542 | - neon()->authManager->revokeAll($this->id); |
|
550 | + if ($this->id) { |
|
551 | + neon()->authManager->revokeAll($this->id); |
|
552 | + } |
|
543 | 553 | return parent::beforeDelete(); |
544 | 554 | } |
545 | 555 |
@@ -140,7 +140,7 @@ |
||
140 | 140 | public static function getInvite($token) |
141 | 141 | { |
142 | 142 | static $_invite; |
143 | - if ($_invite === null){ |
|
143 | + if ($_invite === null) { |
|
144 | 144 | $_invite = self::findOne(['token' => $token]); |
145 | 145 | } |
146 | 146 | return $_invite; |
@@ -110,8 +110,9 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public static function findInviteByInviteToken($token, $ignoreExpiry = false) |
112 | 112 | { |
113 | - if (!$ignoreExpiry && self::hasInviteTokenExpired($token)) |
|
114 | - return null; |
|
113 | + if (!$ignoreExpiry && self::hasInviteTokenExpired($token)) { |
|
114 | + return null; |
|
115 | + } |
|
115 | 116 | |
116 | 117 | return self::findOne(['token' => $token]); |
117 | 118 | } |
@@ -154,7 +155,9 @@ discard block |
||
154 | 155 | public static function hasInviteTokenExpired($token) |
155 | 156 | { |
156 | 157 | $invite = self::getInvite($token); |
157 | - if (!$invite) return false; |
|
158 | + if (!$invite) { |
|
159 | + return false; |
|
160 | + } |
|
158 | 161 | return strtotime($invite->expires_at) <= time(); |
159 | 162 | } |
160 | 163 |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $this->addTextColumn('impersonate')->setFilter(false); |
46 | 46 | // scopes |
47 | 47 | // $this->addScope('all','All'); |
48 | - $this->addScope('active','Active'); |
|
49 | - $this->addScope('pending','Pending'); |
|
50 | - $this->addScope('suspended','Suspended'); |
|
51 | - $this->addScope('banned','Banned'); |
|
48 | + $this->addScope('active', 'Active'); |
|
49 | + $this->addScope('pending', 'Pending'); |
|
50 | + $this->addScope('suspended', 'Suspended'); |
|
51 | + $this->addScope('banned', 'Banned'); |
|
52 | 52 | $this->addScope('super', 'Super'); |
53 | 53 | |
54 | 54 | $this->setPageSize(100); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | */ |
197 | 197 | private function getRoles() |
198 | 198 | { |
199 | - static $roles=null; |
|
199 | + static $roles = null; |
|
200 | 200 | if (is_null($roles)) { |
201 | 201 | $roles = neon('user')->getRoles(true); |
202 | 202 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | */ |
211 | 211 | private function getRoleLabels() |
212 | 212 | { |
213 | - static $labels=null; |
|
213 | + static $labels = null; |
|
214 | 214 | if (is_null($labels)) { |
215 | 215 | $roles = $this->getRoles(); |
216 | 216 | foreach ($roles as $role => $details) |
@@ -41,8 +41,9 @@ discard block |
||
41 | 41 | $this->addTextColumn('created_at'); |
42 | 42 | $this->addTextColumn('updated_at', ['title'=>'Updated At']); |
43 | 43 | // action |
44 | - if (neon()->user->isSuper()) |
|
45 | - $this->addTextColumn('impersonate')->setFilter(false); |
|
44 | + if (neon()->user->isSuper()) { |
|
45 | + $this->addTextColumn('impersonate')->setFilter(false); |
|
46 | + } |
|
46 | 47 | // scopes |
47 | 48 | // $this->addScope('all','All'); |
48 | 49 | $this->addScope('active','Active'); |
@@ -104,8 +105,9 @@ discard block |
||
104 | 105 | $userRoles = explode('|', $column->getCellData($model)); |
105 | 106 | $displayRoles = []; |
106 | 107 | foreach ($userRoles as $ur) { |
107 | - if (isset($roles[$ur])) |
|
108 | - $displayRoles[] = $column->highlight($roles[$ur]['label'], $search); |
|
108 | + if (isset($roles[$ur])) { |
|
109 | + $displayRoles[] = $column->highlight($roles[$ur]['label'], $search); |
|
110 | + } |
|
109 | 111 | } |
110 | 112 | return implode(', ', $displayRoles); |
111 | 113 | } |
@@ -213,8 +215,9 @@ discard block |
||
213 | 215 | static $labels=null; |
214 | 216 | if (is_null($labels)) { |
215 | 217 | $roles = $this->getRoles(); |
216 | - foreach ($roles as $role => $details) |
|
217 | - $labels[$details['label']] = $role; |
|
218 | + foreach ($roles as $role => $details) { |
|
219 | + $labels[$details['label']] = $role; |
|
220 | + } |
|
218 | 221 | } |
219 | 222 | return $labels; |
220 | 223 | } |
@@ -230,8 +233,9 @@ discard block |
||
230 | 233 | $labels = $this->getRoleLabels(); |
231 | 234 | $roles = []; |
232 | 235 | foreach ($labels as $label => $role) { |
233 | - if (stripos($label, $filter) !== false) |
|
234 | - $roles[] = $role; |
|
236 | + if (stripos($label, $filter) !== false) { |
|
237 | + $roles[] = $role; |
|
238 | + } |
|
235 | 239 | } |
236 | 240 | return $roles; |
237 | 241 | } |
@@ -113,13 +113,13 @@ discard block |
||
113 | 113 | try { |
114 | 114 | $jwt = (array) JWT::decode($cookieString, static::secret(), ['HS256']); |
115 | 115 | } catch (Exception $e) { |
116 | - throw new UnauthorizedHttpException('Your request was made with invalid credentials.' . neon()->debug ? ' Can not decode JWT token' : ''); |
|
116 | + throw new UnauthorizedHttpException('Your request was made with invalid credentials.'.neon()->debug ? ' Can not decode JWT token' : ''); |
|
117 | 117 | } |
118 | 118 | // We will compare the CSRF token in the decoded API token against the CSRF header |
119 | 119 | // sent with the request. If the two don't match then this request is sent from |
120 | 120 | // an invalid source and we won't authenticate the request for further handling. |
121 | 121 | if (!$this->validCsrf($jwt, $request)) { |
122 | - throw new UnauthorizedHttpException('Your request was made with invalid credentials.' . neon()->debug ? ' CSRF validation failed' : ''); |
|
122 | + throw new UnauthorizedHttpException('Your request was made with invalid credentials.'.neon()->debug ? ' CSRF validation failed' : ''); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $jwt; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | */ |
216 | 216 | protected static function requestShouldReceiveFreshToken(Request $request) |
217 | 217 | { |
218 | - return $request->isMethod('GET') && neon()->user->isLoggedIn() && ! $request->getIsAjax(); |
|
218 | + return $request->isMethod('GET') && neon()->user->isLoggedIn() && !$request->getIsAjax(); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | /** |
@@ -227,6 +227,6 @@ discard block |
||
227 | 227 | protected static function responseShouldReceiveFreshToken(Response $response) |
228 | 228 | { |
229 | 229 | // if the cookie already exists do not create another one |
230 | - return ! isset($response->cookies[static::$cookieName]); |
|
230 | + return !isset($response->cookies[static::$cookieName]); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | \ No newline at end of file |
@@ -56,8 +56,9 @@ discard block |
||
56 | 56 | // As there is no cookie or cookie string we return null allowing other authentication methods |
57 | 57 | // to attempt authentication |
58 | 58 | $tokenString = $this->getJwtStringFromCookie($request); |
59 | - if ($tokenString === null) |
|
60 | - return null; |
|
59 | + if ($tokenString === null) { |
|
60 | + return null; |
|
61 | + } |
|
61 | 62 | // decode the cookie and perform csrf validation |
62 | 63 | // this only checks that the cookie data is good |
63 | 64 | $jwt = $this->decodeAndValidateJwtToken($tokenString, $request); |
@@ -69,8 +70,9 @@ discard block |
||
69 | 70 | // @see self::findAndValidateUserIdentity() |
70 | 71 | // this is similar to the stock yii classes yii\filters\auth\HttpBearerAuth and yii\filters\auth\QueryParamAuth; |
71 | 72 | $identity = $user->loginByAccessToken($jwt, get_class($this)); |
72 | - if ($identity === null) |
|
73 | - $this->handleFailure($response); |
|
73 | + if ($identity === null) { |
|
74 | + $this->handleFailure($response); |
|
75 | + } |
|
74 | 76 | |
75 | 77 | return $identity; |
76 | 78 | } |
@@ -132,8 +134,9 @@ discard block |
||
132 | 134 | */ |
133 | 135 | public function getJwtStringFromCookie(Request $request) |
134 | 136 | { |
135 | - if (!$request->cookies->has(static::$cookieName)) |
|
136 | - return null; |
|
137 | + if (!$request->cookies->has(static::$cookieName)) { |
|
138 | + return null; |
|
139 | + } |
|
137 | 140 | $cookie = $request->cookies->get(static::$cookieName)->value; |
138 | 141 | return $cookie; |
139 | 142 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | */ |
91 | 91 | public function getHttpBasicAuthorizationBase64() |
92 | 92 | { |
93 | - return base64_encode($this->user_id . ':' . $this->token); |
|
93 | + return base64_encode($this->user_id.':'.$this->token); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @param string $name |
111 | 111 | * @return UserApiToken|null |
112 | 112 | */ |
113 | - public static function generateTokenFor($userId, $name='') |
|
113 | + public static function generateTokenFor($userId, $name = '') |
|
114 | 114 | { |
115 | 115 | $token = UserApiToken::getTokenRecord($userId); |
116 | 116 | // extra security: |
@@ -55,17 +55,20 @@ |
||
55 | 55 | public static function getValidUserByToken($token) |
56 | 56 | { |
57 | 57 | $validToken = self::isValidToken($token); |
58 | - if (!$validToken) |
|
59 | - return null; |
|
58 | + if (!$validToken) { |
|
59 | + return null; |
|
60 | + } |
|
60 | 61 | |
61 | 62 | $apiToken = self::findOne(['active' => 1, 'token' => (string) $token]); |
62 | - if ($apiToken == null) |
|
63 | - return null; |
|
63 | + if ($apiToken == null) { |
|
64 | + return null; |
|
65 | + } |
|
64 | 66 | |
65 | 67 | // TODO: SO 27/10/2018 - update this to be User::findIndentity() - migrate to uuids. |
66 | 68 | $user = User::findOne(['id' => $apiToken->user_id, 'status' => User::STATUS_ACTIVE]); |
67 | - if ($user == null) |
|
68 | - return null; |
|
69 | + if ($user == null) { |
|
70 | + return null; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | // Usage successful |
71 | 74 | $apiToken->touchTokenUsed(); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | /** |
48 | 48 | * @inheritdoc |
49 | 49 | */ |
50 | - public function listUsers(Iterator &$iterator=null) |
|
50 | + public function listUsers(Iterator &$iterator = null) |
|
51 | 51 | { |
52 | 52 | return $this->findUsers(null, $iterator); |
53 | 53 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @inheritdoc |
57 | 57 | */ |
58 | - public function searchUsers($searchString, Iterator &$iterator=null) |
|
58 | + public function searchUsers($searchString, Iterator &$iterator = null) |
|
59 | 59 | { |
60 | 60 | return $this->findUsers(['like', 'username', $searchString], $iterator); |
61 | 61 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | /** |
64 | 64 | * @inheritdoc |
65 | 65 | */ |
66 | - public function addUser($username, $email, $password, $roles=[], $superuser=false) |
|
66 | + public function addUser($username, $email, $password, $roles = [], $superuser = false) |
|
67 | 67 | { |
68 | 68 | $user = new UserModel; |
69 | 69 | $user->uuid = Hash::uuid64(); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | 'uuid'=>$user->uuid, |
96 | 96 | 'username'=>$user->username, |
97 | 97 | 'email'=>$user->email, |
98 | - 'superuser'=>(boolean)$user->super, |
|
98 | + 'superuser'=>(boolean) $user->super, |
|
99 | 99 | 'status' => $user->status, |
100 | 100 | 'roles'=>$user->getRoles() |
101 | 101 | ]; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | { |
114 | 114 | $user = $this->findUserModel($uuid); |
115 | 115 | if ($user) { |
116 | - $newValues = array_intersect_key($changes, array_flip(['email','password','roles'])); |
|
116 | + $newValues = array_intersect_key($changes, array_flip(['email', 'password', 'roles'])); |
|
117 | 117 | foreach ($newValues as $key=>$value) { |
118 | 118 | $user->$key = $value; |
119 | 119 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * for the query. |
154 | 154 | * @param Iterator $iterator an iterator to go over the query |
155 | 155 | */ |
156 | - private function findUsers($where, Iterator &$iterator=null) |
|
156 | + private function findUsers($where, Iterator &$iterator = null) |
|
157 | 157 | { |
158 | 158 | $iterator = $iterator ? $iterator : new Iterator; |
159 | 159 | |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } |
164 | 164 | |
165 | 165 | // get the rows |
166 | - $query = UserModel::find()->select(['uuid','username']) |
|
166 | + $query = UserModel::find()->select(['uuid', 'username']) |
|
167 | 167 | ->limit($iterator->length) |
168 | 168 | ->offset($iterator->start) |
169 | 169 | ->orderBy('username'); |
@@ -29,8 +29,9 @@ discard block |
||
29 | 29 | { |
30 | 30 | $auth = neon()->authManager; |
31 | 31 | $authRole = $auth->createRole($role); |
32 | - if ($authRole) |
|
33 | - $auth->add($authRole); |
|
32 | + if ($authRole) { |
|
33 | + $auth->add($authRole); |
|
34 | + } |
|
34 | 35 | } |
35 | 36 | |
36 | 37 | /** |
@@ -40,8 +41,9 @@ discard block |
||
40 | 41 | { |
41 | 42 | $auth = neon()->authManager; |
42 | 43 | $authRole = $auth->getRole($role); |
43 | - if ($authRole) |
|
44 | - $auth->remove($authRole); |
|
44 | + if ($authRole) { |
|
45 | + $auth->remove($authRole); |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | |
47 | 49 | /** |
@@ -70,8 +72,9 @@ discard block |
||
70 | 72 | $user->username = $username; |
71 | 73 | $user->email = $email; |
72 | 74 | $user->setPassword($password); |
73 | - if ($superuser && neon()->user->isSuper()) |
|
74 | - $user->super = $superuser; |
|
75 | + if ($superuser && neon()->user->isSuper()) { |
|
76 | + $user->super = $superuser; |
|
77 | + } |
|
75 | 78 | $user->generateAuthKey(); |
76 | 79 | $success = $user->save(); |
77 | 80 | if ($success) { |
@@ -117,8 +120,9 @@ discard block |
||
117 | 120 | foreach ($newValues as $key=>$value) { |
118 | 121 | $user->$key = $value; |
119 | 122 | } |
120 | - if (isset($changes['superuser'])) |
|
121 | - $user->__set_super($changes['superuser']); |
|
123 | + if (isset($changes['superuser'])) { |
|
124 | + $user->__set_super($changes['superuser']); |
|
125 | + } |
|
122 | 126 | $success = $user->save(); |
123 | 127 | return $success ? true : $user->errors; |
124 | 128 | } |
@@ -132,8 +136,9 @@ discard block |
||
132 | 136 | public function destroyUser($uuid) |
133 | 137 | { |
134 | 138 | $user = $this->findUserModel($uuid); |
135 | - if ($user) |
|
136 | - $user->delete(); |
|
139 | + if ($user) { |
|
140 | + $user->delete(); |
|
141 | + } |
|
137 | 142 | } |
138 | 143 | |
139 | 144 | |
@@ -168,15 +173,17 @@ discard block |
||
168 | 173 | ->offset($iterator->start) |
169 | 174 | ->orderBy('username'); |
170 | 175 | |
171 | - if ($where) |
|
172 | - $query->where($where); |
|
176 | + if ($where) { |
|
177 | + $query->where($where); |
|
178 | + } |
|
173 | 179 | |
174 | 180 | $userRows = $query->all(); |
175 | 181 | |
176 | 182 | // and return in required format |
177 | 183 | $users = []; |
178 | - foreach ($userRows as $ur) |
|
179 | - $users[$ur['uuid']] = $ur['username']; |
|
184 | + foreach ($userRows as $ur) { |
|
185 | + $users[$ur['uuid']] = $ur['username']; |
|
186 | + } |
|
180 | 187 | return $users; |
181 | 188 | } |
182 | 189 |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @param int $size |
227 | 227 | * @return string |
228 | 228 | */ |
229 | - public function getGuestUserImageUrl($size=40) |
|
229 | + public function getGuestUserImageUrl($size = 40) |
|
230 | 230 | { |
231 | 231 | return "//www.gravatar.com/avatar?d=mm&s=$size"; |
232 | 232 | } |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | /** |
235 | 235 | * @inheritdoc |
236 | 236 | */ |
237 | - public function getImageUrl($size=40) |
|
237 | + public function getImageUrl($size = 40) |
|
238 | 238 | { |
239 | 239 | return $this->noIdentity() ? $this->getGuestUserImageUrl($size) : $this->identity->getImageUrl($size); |
240 | 240 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | /** |
277 | 277 | * @inheritdoc |
278 | 278 | */ |
279 | - public function getHomeUrl($role=null) |
|
279 | + public function getHomeUrl($role = null) |
|
280 | 280 | { |
281 | 281 | return $this->noIdentity() ? null : $this->identity->getHomeUrl($role); |
282 | 282 | } |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | foreach ($userRoles as $ur) { |
296 | 296 | if (array_key_exists('homeUrl', $appRoles[$ur])) { |
297 | 297 | $url = $appRoles[$ur]['homeUrl']; |
298 | - return parent::getReturnUrl( is_array($url) ? $url : [ $url ]); |
|
298 | + return parent::getReturnUrl(is_array($url) ? $url : [$url]); |
|
299 | 299 | } |
300 | 300 | } |
301 | 301 | |
302 | 302 | // use the default or application set one |
303 | 303 | if ($defaultUrl) |
304 | - return parent::getReturnUrl( is_array($defaultUrl) ? $defaultUrl : [ $defaultUrl ] ); |
|
304 | + return parent::getReturnUrl(is_array($defaultUrl) ? $defaultUrl : [$defaultUrl]); |
|
305 | 305 | |
306 | 306 | return parent::getReturnUrl(); |
307 | 307 | } |
@@ -107,8 +107,9 @@ discard block |
||
107 | 107 | $log = "User '$id' logged in from $ip. Session not enabled."; |
108 | 108 | } |
109 | 109 | |
110 | - if (neon()->getRequest()->enableCsrfValidation) |
|
111 | - $this->regenerateCsrfToken(); |
|
110 | + if (neon()->getRequest()->enableCsrfValidation) { |
|
111 | + $this->regenerateCsrfToken(); |
|
112 | + } |
|
112 | 113 | |
113 | 114 | \Yii::info($log, __METHOD__); |
114 | 115 | $this->afterLogin($identity, false, $duration); |
@@ -300,8 +301,9 @@ discard block |
||
300 | 301 | } |
301 | 302 | |
302 | 303 | // use the default or application set one |
303 | - if ($defaultUrl) |
|
304 | - return parent::getReturnUrl( is_array($defaultUrl) ? $defaultUrl : [ $defaultUrl ] ); |
|
304 | + if ($defaultUrl) { |
|
305 | + return parent::getReturnUrl( is_array($defaultUrl) ? $defaultUrl : [ $defaultUrl ] ); |
|
306 | + } |
|
305 | 307 | |
306 | 308 | return parent::getReturnUrl(); |
307 | 309 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | return neon()->mailer->compose($templates, $templateData) |
50 | 50 | ->setTo($user->email) |
51 | 51 | ->setFrom([$fromAddress => $fromName]) |
52 | - ->setSubject($siteName.' invitation for ' . $user->email) |
|
52 | + ->setSubject($siteName.' invitation for '.$user->email) |
|
53 | 53 | ->send(); |
54 | 54 | } |
55 | 55 | } |
@@ -27,8 +27,9 @@ |
||
27 | 27 | $fromName = setting('admin', 'fromEmailName', neon()->name); |
28 | 28 | $fromAddress = setting('admin', 'fromEmailAddress', 'system@'.neon()->request->getHostName()); |
29 | 29 | |
30 | - if (!$fromAddress) |
|
31 | - throw new \Exception('The From Address needs to be set in the admin section for emails'); |
|
30 | + if (!$fromAddress) { |
|
31 | + throw new \Exception('The From Address needs to be set in the admin section for emails'); |
|
32 | + } |
|
32 | 33 | |
33 | 34 | $templates = [ |
34 | 35 | 'html' => '@neon/user/views/mail/userInviteToken-html', |