Esempio n. 1
0
 /**
  * Creates a password reset request.
  *
  * @param string $identifyingField
  * the identifying field to grab an user, likely the email
  * @param string $identifyingValue
  * the identifying value to grab an user, likely the email
  *
  * @return null|string
  * the token of the password reset instance ready to be send to the user via
  * a secondary channel like email; might be null if the user could not be
  * identified uniquly via the given parameters: either zero or more than one
  * users were found
  */
 public function requestPasswordReset($identifyingField, $identifyingValue)
 {
     $users = $this->userData->listEntries([$identifyingField => $identifyingValue]);
     if (count($users) !== 1) {
         return null;
     }
     $user = $users[0];
     $userSetup = new UserSetup();
     do {
         $token = $userSetup->getSalt(32);
         $tokenFound = $this->passwordResetData->countBy($this->passwordResetData->getDefinition()->getTable(), ['token' => $token], ['token' => '='], true) === 0;
     } while (!$tokenFound);
     $passwordReset = $this->passwordResetData->createEmpty();
     $passwordReset->set('user', $user->get('id'));
     $passwordReset->set('token', $token);
     $this->passwordResetData->create($passwordReset);
     return $token;
 }
Esempio n. 2
0
 public function testGetSalt()
 {
     $userSetup = new UserSetup();
     $read = $userSetup->getSalt(40);
     $this->assertTrue(strlen($read) === 40);
 }