@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | class DbSession extends \yii\web\DbSession |
17 | 17 | { |
18 | - protected function composeFields($id=null, $data=null) |
|
18 | + protected function composeFields($id = null, $data = null) |
|
19 | 19 | { |
20 | 20 | // NOTE: do not interact with the identity inside this call |
21 | 21 | // this will trigger a "session_regenerate_id(): Cannot call session save handler in a recursive manner" error |
@@ -103,12 +103,14 @@ |
||
103 | 103 | if ($loggedInUser->isSuper()) { |
104 | 104 | if ($loggedInUser->getId() != $id) { |
105 | 105 | $user = $this->findModel($id); |
106 | - if ($user->delete()) |
|
107 | - neon()->session->setFlash('success', 'The user has been successfully deleted'); |
|
108 | - else |
|
109 | - neon()->session->setFlash('error', 'Something went wrong while trying to delete the user'); |
|
110 | - } else |
|
111 | - neon()->session->setFlash('error', 'Sorry, you cannot delete yourself from the system.'); |
|
106 | + if ($user->delete()) { |
|
107 | + neon()->session->setFlash('success', 'The user has been successfully deleted'); |
|
108 | + } else { |
|
109 | + neon()->session->setFlash('error', 'Something went wrong while trying to delete the user'); |
|
110 | + } |
|
111 | + } else { |
|
112 | + neon()->session->setFlash('error', 'Sorry, you cannot delete yourself from the system.'); |
|
113 | + } |
|
112 | 114 | return $this->redirect(['/user/index/index']); |
113 | 115 | } |
114 | 116 | neon()->session->setFlash('error', 'You do not have permissions to delete the user'); |
@@ -26,18 +26,18 @@ |
||
26 | 26 | [ |
27 | 27 | 'allow' => true, |
28 | 28 | 'actions' => ['login', 'logout', 'request-password-reset', 'reset-password', 'impersonate-restore'], |
29 | - 'roles' => [ '?', '@' ] // any guest user or logged in user |
|
29 | + 'roles' => ['?', '@'] // any guest user or logged in user |
|
30 | 30 | ], |
31 | 31 | [ |
32 | 32 | 'allow' => setting('user', 'allowUserInvitations', false), // Allow registration if allowed in settings |
33 | 33 | 'actions' => ['register'], |
34 | - 'roles' => [ '?', '@' ] |
|
34 | + 'roles' => ['?', '@'] |
|
35 | 35 | ], |
36 | 36 | // allow users with neon-administrator access to all functions defined |
37 | 37 | [ |
38 | 38 | 'allow' => true, |
39 | 39 | 'actions' => ['index', 'impersonate'], |
40 | - 'roles' => [ 'neon-administrator' ] |
|
40 | + 'roles' => ['neon-administrator'] |
|
41 | 41 | ], |
42 | 42 | // everything else is denied |
43 | 43 | ]; |
@@ -87,11 +87,11 @@ |
||
87 | 87 | // allow authenticated users if invites are allowed |
88 | 88 | [ |
89 | 89 | 'allow' => setting('user', 'allowUserInvitations', false), |
90 | - 'roles' => [ 'neon-administrator' ] |
|
90 | + 'roles' => ['neon-administrator'] |
|
91 | 91 | ], |
92 | 92 | [ |
93 | 93 | 'allow' => setting('user', 'allowUserInvitations', false), |
94 | - 'matchCallback' => function ($rule, $action) { |
|
94 | + 'matchCallback' => function($rule, $action) { |
|
95 | 95 | return neon()->user->isSuper(); |
96 | 96 | } |
97 | 97 | ] |
@@ -27,15 +27,18 @@ discard block |
||
27 | 27 | $user->username = $this->getField('username')->getValue(); |
28 | 28 | $user->email = $this->getField('email')->getValue(); |
29 | 29 | $password = $this->getField('password')->getValue(); |
30 | - if (strlen($password) >= setting('user', 'minimumPasswordLength', self::MIN_PASSWORD_LENGTH)) |
|
31 | - $user->setPassword($password); |
|
30 | + if (strlen($password) >= setting('user', 'minimumPasswordLength', self::MIN_PASSWORD_LENGTH)) { |
|
31 | + $user->setPassword($password); |
|
32 | + } |
|
32 | 33 | $user->generateAuthKey(); |
33 | 34 | $user->status = $this->getField('status')->getValue(); |
34 | - if (neon()->user->isSuper()) |
|
35 | - $user->super = $this->getField('super')->getValue(); |
|
35 | + if (neon()->user->isSuper()) { |
|
36 | + $user->super = $this->getField('super')->getValue(); |
|
37 | + } |
|
36 | 38 | $success = $user->save(); |
37 | - if ($success) |
|
38 | - $user->setRoles($this->getField('roles')->getValue()); |
|
39 | + if ($success) { |
|
40 | + $user->setRoles($this->getField('roles')->getValue()); |
|
41 | + } |
|
39 | 42 | } |
40 | 43 | return $success; |
41 | 44 | } |
@@ -43,7 +46,8 @@ discard block |
||
43 | 46 | public function load($user = null) |
44 | 47 | { |
45 | 48 | parent::load($user); |
46 | - if ($user) |
|
47 | - $this->getField('roles')->setValue($user->getRoles()); |
|
49 | + if ($user) { |
|
50 | + $this->getField('roles')->setValue($user->getRoles()); |
|
51 | + } |
|
48 | 52 | } |
49 | 53 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | if (User::hasPasswordResetTokenExpired($token)) { |
43 | 43 | throw new InvalidArgumentException('This password reset token has expired.'); |
44 | 44 | } |
45 | - if ( !$this->_user ) { |
|
45 | + if (!$this->_user) { |
|
46 | 46 | throw new InvalidArgumentException('Wrong password reset token.'); |
47 | 47 | } |
48 | 48 | parent::__construct($config); |
@@ -98,7 +98,7 @@ |
||
98 | 98 | return $roleItems; |
99 | 99 | } |
100 | 100 | |
101 | - public function signupNewUser(&$user=null) |
|
101 | + public function signupNewUser(&$user = null) |
|
102 | 102 | { |
103 | 103 | if ($this->validate()) { |
104 | 104 | $user = new User; |
@@ -25,8 +25,9 @@ discard block |
||
25 | 25 | 'unique' => ['targetClass' => '\neon\user\models\User', 'message' => 'This username has already been taken.'], |
26 | 26 | 'string' => ['min' => 2, 'max' => 255] |
27 | 27 | ]; |
28 | - if ($this->editing) |
|
29 | - unset($userNameValidators['unique']); |
|
28 | + if ($this->editing) { |
|
29 | + unset($userNameValidators['unique']); |
|
30 | + } |
|
30 | 31 | $this->addFieldText('username') |
31 | 32 | ->setLabel('Username') |
32 | 33 | ->setValidators($userNameValidators); |
@@ -38,8 +39,9 @@ discard block |
||
38 | 39 | 'string' => ['min'=>5, 'max' => 255], |
39 | 40 | 'unique' => ['targetClass' => '\neon\user\models\User', 'message' => 'This email address has already been taken.'] |
40 | 41 | ]; |
41 | - if ($this->editing) |
|
42 | - unset($emailValidators['unique']); |
|
42 | + if ($this->editing) { |
|
43 | + unset($emailValidators['unique']); |
|
44 | + } |
|
43 | 45 | $this->addFieldEmail('email') |
44 | 46 | ->setLabel('Email') |
45 | 47 | ->setValidators($emailValidators); |
@@ -105,8 +107,9 @@ discard block |
||
105 | 107 | $user->username = $this->getField('username')->getValue(); |
106 | 108 | $user->email = $this->getField('email')->getValue(); |
107 | 109 | $user->setPassword($this->getField('password')->getValue()); |
108 | - if (neon()->user->isSuper()) |
|
109 | - $user->super = $this->getField('super')->getValue(); |
|
110 | + if (neon()->user->isSuper()) { |
|
111 | + $user->super = $this->getField('super')->getValue(); |
|
112 | + } |
|
110 | 113 | $user->generateAuthKey(); |
111 | 114 | $success = $user->save(); |
112 | 115 | if ($success) { |
@@ -68,7 +68,7 @@ |
||
68 | 68 | return neon()->mailer->compose($templates, $templateData) |
69 | 69 | ->setFrom([$fromAddress => $fromName]) |
70 | 70 | ->setTo($this->email) |
71 | - ->setSubject('Password reset for ' . $siteName) |
|
71 | + ->setSubject('Password reset for '.$siteName) |
|
72 | 72 | ->send(); |
73 | 73 | } |
74 | 74 | } |
@@ -48,8 +48,9 @@ |
||
48 | 48 | if ($user->save()) { |
49 | 49 | $fromName = setting('admin', 'fromEmailName', neon()->name); |
50 | 50 | $fromAddress = setting('admin', 'fromEmailAddress', 'system@'.neon()->request->getHostName()); |
51 | - if (!$fromAddress) |
|
52 | - throw new \Exception('The From Address needs to be set in the admin section for emails'); |
|
51 | + if (!$fromAddress) { |
|
52 | + throw new \Exception('The From Address needs to be set in the admin section for emails'); |
|
53 | + } |
|
53 | 54 | |
54 | 55 | $templates = [ |
55 | 56 | 'html' => '@neon/user/views/mail/passwordResetToken-html', |
@@ -70,8 +70,9 @@ |
||
70 | 70 | $user = new User; |
71 | 71 | $user->email = $this->getField('email')->getValue(); |
72 | 72 | $user->status = User::STATUS_PENDING; |
73 | - if (neon()->user->isSuper()) |
|
74 | - $user->super = $this->getField('super')->getValue(); |
|
73 | + if (neon()->user->isSuper()) { |
|
74 | + $user->super = $this->getField('super')->getValue(); |
|
75 | + } |
|
75 | 76 | $user->setPassword(neon()->security->generateRandomString(32)); |
76 | 77 | if (!$user->save()) { |
77 | 78 | return false; |