Add totp field for Minecraft auth protocol to login into accounts, protected with 2FA [deploy]

This commit is contained in:
ErickSkrauch
2021-03-08 11:26:47 +01:00
parent 125caa7e4e
commit 9a3534ea2b
3 changed files with 38 additions and 0 deletions

View File

@ -29,6 +29,11 @@ class AuthenticationForm extends ApiForm {
*/
public $password;
/**
* @var string
*/
public $totp;
/**
* @var string
*/
@ -42,6 +47,7 @@ class AuthenticationForm extends ApiForm {
public function rules(): array {
return [
[['username', 'password', 'clientToken'], RequiredValidator::class],
[['totp'], 'string'],
[['clientToken'], ClientTokenValidator::class],
[['requestUser'], 'boolean'],
];
@ -65,6 +71,7 @@ class AuthenticationForm extends ApiForm {
$loginForm = new LoginForm();
$loginForm->login = $this->username;
$loginForm->password = $this->password;
$loginForm->totp = $this->totp;
if (!$loginForm->validate() || $loginForm->getAccount()->status === Account::STATUS_DELETED) {
$errors = $loginForm->getFirstErrors();
if (isset($errors['totp'])) {