diff --git a/CHANGELOG.md b/CHANGELOG.md index 31b7b35..bc80d46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ================== +## 3.3.5 - 2024-02-13 +### Fixed +- fix: Missing usertoken table on fresh install + ## 3.3.4 - 2024-02-08 ### Fixed - fix: Exposure of Sensitive Attributes diff --git a/src/migrations/Install.php b/src/migrations/Install.php index f157028..90ee688 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -3,6 +3,7 @@ use craft\db\Migration; use born05\twofactorauthentication\records\User; +use born05\twofactorauthentication\records\UserToken; class Install extends Migration { @@ -23,8 +24,19 @@ public function safeUp() ]); $this->createIndex(null, User::tableName(), ['userId'], true); - $this->addForeignKey(null, User::tableName(), ['userId'], '{{%users}}', ['id'], 'CASCADE', null); + + $this->createTable(UserToken::tableName(), [ + 'id' => $this->primaryKey(), + 'userId' => $this->integer()->notNull(), + 'token' => $this->string(100)->notNull(), + 'dateCreated' => $this->dateTime()->notNull(), + 'dateUpdated' => $this->dateTime()->notNull(), + 'uid' => $this->uid(), + ]); + + $this->createIndex(null, UserToken::tableName(), ['userId', 'dateCreated'], false); + $this->createIndex(null, UserToken::tableName(), ['userId', 'token', 'dateCreated'], true); } protected function upgradeFromCraft2() @@ -46,6 +58,7 @@ public function safeDown() { $this->dropTableIfExists('{{%twofactorauthentication_session}}'); $this->dropTableIfExists(User::tableName()); + $this->dropTableIfExists(UserToken::tableName()); return true; }