Esempio n. 1
0
 /**
  * Returns a user that corresponds to the given reset password token or
  * false if there is no user with the given token.
  *
  * @param string $token
  *
  * @return ConfideUser
  */
 public function userByResetPasswordToken($token)
 {
     $email = $this->passService->getEmailByToken($token);
     if ($email) {
         return $this->repo->getUserByEmail($email);
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Validates if the given user is unique. If there is another
  * user with the same credentials but a different id, this
  * method will return false.
  *
  * @param ConfideUserInterface $user
  *
  * @return boolean True if user is unique.
  */
 public function validateIsUnique(ConfideUserInterface $user)
 {
     $identity = ['email' => $user->email, 'username' => $user->username];
     $identity = array_filter($identity);
     foreach ($identity as $attribute => $value) {
         $similar = $this->repo->getUserByIdentity([$attribute => $value]);
         if (!$similar || $similar->getKey() == $user->getKey()) {
             unset($identity[$attribute]);
         } else {
             $this->attachErrorMsg($user, 'confide::confide.alerts.duplicated_credentials', $attribute);
         }
     }
     if (empty($identity)) {
         return true;
     }
     return false;
 }