Exemplo n.º 1
0
 /**
  *
  * @param UserModel $user
  * @param Website $website
  * @param DeliveryInterface $delivery
  */
 public static function sendForgotPasswordVerification($user, $website, DeliveryInterface $delivery = null)
 {
     $user->setForgotPassword(7);
     $user->write();
     $to = array($user->email => $user->name);
     $subject = $website->name . ' Forgotten Password Verification';
     $vars = array('user' => $user, 'link' => $website->baseUrl() . '/auth/reset_password/' . $user->resetPasswordKey, 'website' => $website);
     self::sendTemplateEmail($to, $subject, 'ForgotPasswordVerification', $vars, $website, $delivery);
 }
Exemplo n.º 2
0
 public function testHasForgottenPassword_KeySetConsumeKey_HasForgottenKeyConsumed()
 {
     $e = new MongoTestEnvironment();
     $e->clean();
     $userId = $e->createUser('user1', 'User1', 'user1');
     $user = new UserModel($userId);
     $user->setForgotPassword(7);
     $user->write();
     $hasForgottenPassword = $user->hasForgottenPassword(true);
     $this->assertTrue($hasForgottenPassword);
     $this->assertFalse($user->resetPasswordKey);
     $today = new \DateTime();
     $hourMargin = 60;
     $this->assertWithinMargin($user->resetPasswordExpirationDate->getTimestamp(), $today->getTimestamp(), $hourMargin);
 }