From 09d25634e2e30257548067ff26571c714796099b Mon Sep 17 00:00:00 2001 From: dpslwk Date: Sat, 25 May 2019 18:27:57 +0100 Subject: [PATCH] User: add recovery codes field --- app/HMS/Entities/User.php | 27 +++++++++++++++++ app/HMS/Mappings/HMS.Entities.User.dcm.yml | 3 ++ ...36_alter_user_google2fa_recovery_codes.php | 29 +++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 database/migrations_doctrine/Version20190525151436_alter_user_google2fa_recovery_codes.php diff --git a/app/HMS/Entities/User.php b/app/HMS/Entities/User.php index 0d93cb4f1..0bb2a5e67 100644 --- a/app/HMS/Entities/User.php +++ b/app/HMS/Entities/User.php @@ -112,6 +112,13 @@ class User implements */ protected $google2faSecret; + /** + * Encrypted recovery codes + * + * @var string + */ + protected $google2faRecoveryCodes; + /** * User constructor. * @@ -445,6 +452,26 @@ public function setGoogle2faSecret($google2faSecret) return $this; } + /** + * @return string + */ + public function getGoogle2faRecoveryCodes() + { + return $this->google2faRecoveryCodes; + } + + /** + * @param string $google2faRecoveryCodes + * + * @return self + */ + public function setGoogle2faRecoveryCodes($google2faRecoveryCodes) + { + $this->google2faRecoveryCodes = $google2faRecoveryCodes; + + return $this; + } + /** * Route notifications for the Nexmo channel. * diff --git a/app/HMS/Mappings/HMS.Entities.User.dcm.yml b/app/HMS/Mappings/HMS.Entities.User.dcm.yml index 73f14fe15..f843fc5cb 100644 --- a/app/HMS/Mappings/HMS.Entities.User.dcm.yml +++ b/app/HMS/Mappings/HMS.Entities.User.dcm.yml @@ -45,6 +45,9 @@ HMS\Entities\User: google2faSecret: type: string nullable: true + google2faRecoveryCodes: + type: string + nullable: true deletedAt: type: datetime nullable: true diff --git a/database/migrations_doctrine/Version20190525151436_alter_user_google2fa_recovery_codes.php b/database/migrations_doctrine/Version20190525151436_alter_user_google2fa_recovery_codes.php new file mode 100644 index 000000000..41543a89b --- /dev/null +++ b/database/migrations_doctrine/Version20190525151436_alter_user_google2fa_recovery_codes.php @@ -0,0 +1,29 @@ +abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE user ADD google2fa_recovery_codes VARCHAR(255) DEFAULT NULL'); + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + $this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); + + $this->addSql('ALTER TABLE user DROP google2fa_recovery_codes'); + } +}