Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Email\Generator\CodeGenerator::generateAndSend PHP Method

generateAndSend() public method

Generate a new authentication code an send it to the user.
public generateAndSend ( Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface $user )
$user Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface
    public function generateAndSend(TwoFactorInterface $user)
    {
        $min = pow(10, $this->digits - 1);
        $max = pow(10, $this->digits) - 1;
        $code = $this->generateCode($min, $max);
        $user->setEmailAuthCode($code);
        $this->persister->persist($user);
        $this->mailer->sendAuthCode($user);
    }

Usage Example

コード例 #1
0
 /**
  * @test
  */
 public function generateAndSend_generateNewCode_sendMail()
 {
     //Stub the user object
     $user = $this->getMock("Scheb\\TwoFactorBundle\\Model\\Email\\TwoFactorInterface");
     //Mock the mailer
     $this->mailer->expects($this->once())->method("sendAuthCode")->with($user);
     $this->authCodeManager->generateAndSend($user);
 }
All Usage Examples Of Scheb\TwoFactorBundle\Security\TwoFactor\Provider\Email\Generator\CodeGenerator::generateAndSend