Skip to content

Commit

Permalink
fix: Missing usertoken table on fresh install
Browse files Browse the repository at this point in the history
  • Loading branch information
Roel van Hintum committed Feb 13, 2024
1 parent 95af537 commit a448751
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 14 additions & 1 deletion src/migrations/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use craft\db\Migration;
use born05\twofactorauthentication\records\User;
use born05\twofactorauthentication\records\UserToken;

class Install extends Migration
{
Expand All @@ -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()
Expand All @@ -46,6 +58,7 @@ public function safeDown()
{
$this->dropTableIfExists('{{%twofactorauthentication_session}}');
$this->dropTableIfExists(User::tableName());
$this->dropTableIfExists(UserToken::tableName());

return true;
}
Expand Down

0 comments on commit a448751

Please # to comment.