cs fixes and docs
This commit is contained in:
@@ -35,7 +35,13 @@ use StdClass;
|
||||
|
||||
interface CodeVerify
|
||||
{
|
||||
/**
|
||||
* Verify a code for a user.
|
||||
*/
|
||||
public function verifyCode(User $user, string $code) : bool;
|
||||
|
||||
/**
|
||||
* Data to be sent to frontend for showing a form for a second step.
|
||||
*/
|
||||
public function getLoginData(User $user) : StdClass;
|
||||
}
|
||||
|
||||
@@ -49,15 +49,27 @@ class Totp implements CodeVerify
|
||||
|
||||
public function verifyCode(User $user, string $code) : bool
|
||||
{
|
||||
$userData = $this->entityManager->getRepository('UserData')->getByUserId($user->id);
|
||||
$userData = $this->entityManager
|
||||
->getRepository('UserData')
|
||||
->getByUserId($user->id);
|
||||
|
||||
if (!$userData) return false;
|
||||
if (!$userData->get('auth2FA')) return false;
|
||||
if ($userData->get('auth2FAMethod') != 'Totp') return false;
|
||||
if (!$userData) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$userData->get('auth2FA')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($userData->get('auth2FAMethod') != 'Totp') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$secret = $userData->get('auth2FATotpSecret');
|
||||
|
||||
if (!$secret) return false;
|
||||
if (!$secret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->totp->verifyCode($secret, $code);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,13 @@ use StdClass;
|
||||
|
||||
interface CodeVerify
|
||||
{
|
||||
/**
|
||||
* Generate data for a user.
|
||||
*/
|
||||
public function generateData(UserData $userData, StdClass $data, string $userName) : StdClass;
|
||||
|
||||
/**
|
||||
* Confirm code before storing.
|
||||
*/
|
||||
public function verify(UserData $userData, string $code) : bool;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,9 @@ class Totp implements CodeVerify
|
||||
|
||||
public function verify(UserData $userData, string $code) : bool
|
||||
{
|
||||
if (!$code) return false;
|
||||
if (!$code) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$code = str_replace(' ', '', trim($code));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user