Skip to content

Commit

Permalink
User: add recovery codes field
Browse files Browse the repository at this point in the history
  • Loading branch information
dpslwk committed May 25, 2019
1 parent 59acca7 commit 09d2563
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
27 changes: 27 additions & 0 deletions app/HMS/Entities/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@ class User implements
*/
protected $google2faSecret;

/**
* Encrypted recovery codes
*
* @var string
*/
protected $google2faRecoveryCodes;

/**
* User constructor.
*
Expand Down Expand Up @@ -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.
*
Expand Down
3 changes: 3 additions & 0 deletions app/HMS/Mappings/HMS.Entities.User.dcm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ HMS\Entities\User:
google2faSecret:
type: string
nullable: true
google2faRecoveryCodes:
type: string
nullable: true
deletedAt:
type: datetime
nullable: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Database\Migrations;

use Doctrine\DBAL\Schema\Schema as Schema;
use Doctrine\Migrations\AbstractMigration;

class Version20190525151436_alter_user_google2fa_recovery_codes extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->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');
}
}

0 comments on commit 09d2563

Please sign in to comment.