Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi factor authentication (OTP = One time password) #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
different interface for otp entities
  • Loading branch information
Lampret, Alexander committed Oct 27, 2021
commit d690a51b250d6ab63e0b3c4779e0fcbd046579ac
6 changes: 5 additions & 1 deletion src/LmcUser/Authentication/Adapter/OtpMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Laminas\ServiceManager\ServiceManager;
use Laminas\Crypt\Password\Bcrypt;
use Laminas\Session\Container as SessionContainer;
use LmcUser\Entity\UserInterface;
use LmcUser\Entity\UserOtpInterface;
use LmcUser\Mapper\UserInterface as UserMapperInterface;
use LmcUser\Options\ModuleOptions;
use LmcUser\Entity\User;
Expand Down Expand Up @@ -62,6 +62,10 @@ public function authenticate(AdapterChainEvent $e)
return;
}

/**
*
* @var UserOtpInterface|null $userObject
*/
$userObject = $this->getMapper()->findById($storage['identity']);
if (!$userObject) {
$e->setCode(AuthenticationResult::FAILURE_IDENTITY_NOT_FOUND)
Expand Down
27 changes: 0 additions & 27 deletions src/LmcUser/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ class User implements UserInterface
*/
protected $state;

/**
* @var bool
*/
protected $useOtp;

/**
* Get id.
*
Expand Down Expand Up @@ -170,26 +165,4 @@ public function setState($state)
$this->state = $state;
return $this;
}

/**
* Get otp usage.
*
* @return bool
*/
public function getUseOtp()
{
return $this->useOtp;
}

/**
* Set otp usage.
*
* @param bool $useOtp
* @return UserInterface
*/
public function setUseOtp($useOtp)
{
$this->useOtp = $useOtp;
return $this;
}
}
15 changes: 0 additions & 15 deletions src/LmcUser/Entity/UserInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,4 @@ public function getState();
* @return UserInterface
*/
public function setState($state);

/**
* Get otp usage.
*
* @return bool
*/
public function getUseOtp();

/**
* Set otp usage.
*
* @param bool $otp
* @return UserInterface
*/
public function setUseOtp($useOtp);
}
111 changes: 111 additions & 0 deletions src/LmcUser/Entity/UserOtpInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace LmcUser\Entity;

interface UserOtpInterface
{
/**
* Get id.
*
* @return int
*/
public function getId();

/**
* Set id.
*
* @param int $id
* @return UserInterface
*/
public function setId($id);

/**
* Get username.
*
* @return string
*/
public function getUsername();

/**
* Set username.
*
* @param string $username
* @return UserInterface
*/
public function setUsername($username);

/**
* Get email.
*
* @return string
*/
public function getEmail();

/**
* Set email.
*
* @param string $email
* @return UserInterface
*/
public function setEmail($email);

/**
* Get displayName.
*
* @return string
*/
public function getDisplayName();

/**
* Set displayName.
*
* @param string $displayName
* @return UserInterface
*/
public function setDisplayName($displayName);

/**
* Get password.
*
* @return string password
*/
public function getPassword();

/**
* Set password.
*
* @param string $password
* @return UserInterface
*/
public function setPassword($password);

/**
* Get state.
*
* @return int
*/
public function getState();

/**
* Set state.
*
* @param int $state
* @return UserInterface
*/
public function setState($state);

/**
* Get otp usage.
*
* @return bool
*/
public function getUseOtp();

/**
* Set otp usage.
*
* @param bool $otp
* @return UserInterface
*/
public function setUseOtp($useOtp);
}