@@ -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) { |
@@ -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 | $userClass = neon()->getUser()->identityClass; |
@@ -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; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | // the key fields in this table are responsible for the session |
15 | 15 | // this is the session id, expire and data fields. After that the next important field is the user_uuid |
16 | 16 | // then the following additional information fields |
17 | - $this->addColumn(\neon\user\models\Session::tableName(), 'user_uuid', $this->uuid64() .' AFTER `data`'); |
|
17 | + $this->addColumn(\neon\user\models\Session::tableName(), 'user_uuid', $this->uuid64().' AFTER `data`'); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | public function safeDown() |
@@ -6,30 +6,30 @@ |
||
6 | 6 | class m170104_26042017_user_api_tokens extends Migration |
7 | 7 | { |
8 | 8 | |
9 | - /** |
|
10 | - * @inheritdoc |
|
11 | - * Install the User, AuthRule, AuthItem, AuthItemChild, AuthAssignment tables |
|
12 | - */ |
|
9 | + /** |
|
10 | + * @inheritdoc |
|
11 | + * Install the User, AuthRule, AuthItem, AuthItemChild, AuthAssignment tables |
|
12 | + */ |
|
13 | 13 | public function safeUp() |
14 | - { |
|
14 | + { |
|
15 | 15 | $sql = "DROP TABLE IF EXISTS ".UserApiToken::tableName(); |
16 | 16 | \Yii::$app->getDb()->createCommand($sql)->execute(); |
17 | 17 | |
18 | - $this->createTable(UserApiToken::tableName(), [ |
|
19 | - 'token'=>'varchar(64) PRIMARY KEY COMMENT "The token"', |
|
20 | - 'name' => 'varchar(100) COMMENT "A name for this token"', |
|
21 | - 'user_id'=>'int COMMENT "foreign key of the user who owns this token"', |
|
22 | - 'active'=>'int not null default 0 COMMENT "whether the token is currently active, 1 is an active token, 0 is a non active token and will not produce successful requests"', |
|
23 | - 'last_used'=>'datetime COMMENT "store the date and time of the last request that used this token"', |
|
24 | - 'used_count'=>'int not null default 0 COMMENT "number of times this token has been used"', |
|
25 | - // timestamps |
|
26 | - 'created_at' => $this->createdAt(), |
|
27 | - 'updated_at' => $this->updatedAt(), |
|
28 | - ]); |
|
29 | - } |
|
18 | + $this->createTable(UserApiToken::tableName(), [ |
|
19 | + 'token'=>'varchar(64) PRIMARY KEY COMMENT "The token"', |
|
20 | + 'name' => 'varchar(100) COMMENT "A name for this token"', |
|
21 | + 'user_id'=>'int COMMENT "foreign key of the user who owns this token"', |
|
22 | + 'active'=>'int not null default 0 COMMENT "whether the token is currently active, 1 is an active token, 0 is a non active token and will not produce successful requests"', |
|
23 | + 'last_used'=>'datetime COMMENT "store the date and time of the last request that used this token"', |
|
24 | + 'used_count'=>'int not null default 0 COMMENT "number of times this token has been used"', |
|
25 | + // timestamps |
|
26 | + 'created_at' => $this->createdAt(), |
|
27 | + 'updated_at' => $this->updatedAt(), |
|
28 | + ]); |
|
29 | + } |
|
30 | 30 | |
31 | - public function safeDown() |
|
32 | - { |
|
33 | - $this->dropTable(UserApiToken::tableName()); |
|
34 | - } |
|
31 | + public function safeDown() |
|
32 | + { |
|
33 | + $this->dropTable(UserApiToken::tableName()); |
|
34 | + } |
|
35 | 35 | } |
@@ -7,17 +7,17 @@ |
||
7 | 7 | { |
8 | 8 | public function safeUp() |
9 | 9 | { |
10 | - $this->createTable(UserInvite::tableName(), [ |
|
11 | - 'token'=>'varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs PRIMARY KEY COMMENT "The token"', |
|
12 | - 'user_id'=> $this->uuid64( 'foreign key of the user who owns this token')->notNull(), |
|
13 | - // timestamps |
|
14 | - 'expires_at' => $this->dateTime(), |
|
15 | - 'created_at' => $this->createdAt(), |
|
16 | - 'updated_at' => $this->updatedAt(), |
|
17 | - // blames |
|
18 | - 'created_by' => $this->createdBy(), |
|
19 | - 'updated_by' => $this->updatedBy() |
|
20 | - ]); |
|
10 | + $this->createTable(UserInvite::tableName(), [ |
|
11 | + 'token'=>'varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs PRIMARY KEY COMMENT "The token"', |
|
12 | + 'user_id'=> $this->uuid64( 'foreign key of the user who owns this token')->notNull(), |
|
13 | + // timestamps |
|
14 | + 'expires_at' => $this->dateTime(), |
|
15 | + 'created_at' => $this->createdAt(), |
|
16 | + 'updated_at' => $this->updatedAt(), |
|
17 | + // blames |
|
18 | + 'created_by' => $this->createdBy(), |
|
19 | + 'updated_by' => $this->updatedBy() |
|
20 | + ]); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function safeDown() |
@@ -9,7 +9,7 @@ |
||
9 | 9 | { |
10 | 10 | $this->createTable(UserInvite::tableName(), [ |
11 | 11 | 'token'=>'varchar(255) CHARACTER SET latin1 COLLATE latin1_general_cs PRIMARY KEY COMMENT "The token"', |
12 | - 'user_id'=> $this->uuid64( 'foreign key of the user who owns this token')->notNull(), |
|
12 | + 'user_id'=> $this->uuid64('foreign key of the user who owns this token')->notNull(), |
|
13 | 13 | // timestamps |
14 | 14 | 'expires_at' => $this->dateTime(), |
15 | 15 | 'created_at' => $this->createdAt(), |
@@ -71,22 +71,22 @@ |
||
71 | 71 | 'created_at' => $this->integer(), |
72 | 72 | 'updated_at' => $this->integer(), |
73 | 73 | 'PRIMARY KEY (name)', |
74 | - 'FOREIGN KEY (rule_name) REFERENCES ' . neon()->authManager->ruleTable . ' (name) ON DELETE SET NULL ON UPDATE CASCADE' |
|
74 | + 'FOREIGN KEY (rule_name) REFERENCES '.neon()->authManager->ruleTable.' (name) ON DELETE SET NULL ON UPDATE CASCADE' |
|
75 | 75 | ]); |
76 | 76 | $this->createIndex('idx-auth_item-type', AuthItem::tableName(), 'type'); |
77 | 77 | $this->createTable(AuthItemChild::tableName(), [ |
78 | 78 | 'parent' => $this->string(64)->notNull(), |
79 | 79 | 'child' => $this->string(64)->notNull(), |
80 | 80 | 'PRIMARY KEY (parent, child)', |
81 | - 'FOREIGN KEY (parent) REFERENCES ' . neon()->authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
82 | - 'FOREIGN KEY (child) REFERENCES ' . neon()->authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE' |
|
81 | + 'FOREIGN KEY (parent) REFERENCES '.neon()->authManager->itemTable.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
82 | + 'FOREIGN KEY (child) REFERENCES '.neon()->authManager->itemTable.' (name) ON DELETE CASCADE ON UPDATE CASCADE' |
|
83 | 83 | ]); |
84 | 84 | $this->createTable(AuthAssignment::tableName(), [ |
85 | 85 | 'item_name' => $this->string(64)->notNull(), |
86 | 86 | 'user_id' => $this->string(64)->notNull(), |
87 | 87 | 'created_at' => $this->integer(), |
88 | 88 | 'PRIMARY KEY (item_name, user_id)', |
89 | - 'FOREIGN KEY (item_name) REFERENCES ' . neon()->authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
89 | + 'FOREIGN KEY (item_name) REFERENCES '.neon()->authManager->itemTable.' (name) ON DELETE CASCADE ON UPDATE CASCADE', |
|
90 | 90 | ]); |
91 | 91 | $this->createTable(Session::tableName(), [ |
92 | 92 | 'id' => 'CHAR(64) NOT NULL PRIMARY KEY', |
@@ -25,7 +25,7 @@ |
||
25 | 25 | public function safeDown() |
26 | 26 | { |
27 | 27 | $auth = neon()->authManager; |
28 | - $auth->removeAll(); |
|
28 | + $auth->removeAll(); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | } |
32 | 32 | \ No newline at end of file |
@@ -17,8 +17,9 @@ |
||
17 | 17 | $this->addColumn(User::tableName(), 'uuid', 'char(22) AFTER `id`'); |
18 | 18 | // fetch 50 users at a time and iterate them one by one |
19 | 19 | // save call will automatically create the uuid if it currently does not exist |
20 | - foreach (User::find()->each(50) as $user) |
|
21 | - $user->save(false, [User::UUID]); |
|
20 | + foreach (User::find()->each(50) as $user) { |
|
21 | + $user->save(false, [User::UUID]); |
|
22 | + } |
|
22 | 23 | // create a unique index |
23 | 24 | $this->createIndex('uuid', User::tableName(), 'uuid', true); |
24 | 25 | } |