Validate a email verification for the given credentials.

@param  array  $credentials
@return \Lunaweb\User\Auth\CanVerifyEmailContract
508404
protected function validateEmailVerification(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

        if (! $this->validateToken($user, $credentials)) {
            return static::INVALID_TOKEN;
        }

        if (! $this->validateTimestamp($credentials['expiration'])) {
            return static::EXPIRED_TOKEN;
        }

        return $user;
    }
669732
public function retrieveByCredentials(array $credentials)
    {
        if (empty($credentials) ||
           (count($credentials) === 1 &&
            array_key_exists('password', $credentials))) {
            return;
        }

        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // generic "user" object that will be utilized by the Guard instances.
        $query = $this->conn->table($this->table);

        foreach ($credentials as $key => $value) {
            if (Str::contains($key, 'password')) {
                continue;
            }

            if (is_array($value) || $value instanceof Arrayable) {
                $query->whereIn($key, $value);
            } else {
                $query->where($key, $value);
            }
        }

        // Now we are ready to execute the query to see if we have an user matching
        // the given credentials. If not, we will just return nulls and indicate
        // that there are no matching users for these given credential arrays.
        $user = $query->first();

        return $this->getGenericUser($user);
    }
960103
protected function validatePasswordWithDefaults(array $credentials)
    {
        [$password, $confirm] = [
            $credentials['password'],
            $credentials['password_confirmation'],
        ];

        return $password === $confirm && mb_strlen($password) >= 8;
    }
223217
public function validateCredentials(Authenticatable $user, array $credentials)
    {
        if (! app('hash')->check($credentials['password'], $user->password)) {
            return false;
        }

        return true;
    }
1356712
public function authenticate(array $credentials): Identity
	{
		list($username, $password) = $credentials;

		$user = $this->orm->users->getByUsername($username);

		if (!$user) {
			throw new AuthenticationException('The username is incorrect.', self::IDENTITY_NOT_FOUND);
		} elseif (!Passwords::verify($password, $user->password)) {
			throw new AuthenticationException('The password is incorrect.', self::INVALID_CREDENTIAL);
		} elseif (!$user->active) {
			throw new AuthenticationException('Account is deactivated.', self::NOT_APPROVED);
		} elseif (Passwords::needsRehash($user->password)) {
			$user->setPassword($password);
			$this->orm->persistAndFlush($user);
		}

		return new Identity($user->id);
	}
440332
public function verify($credentials)
    {
        if(!array_key_exists("jwt", $credentials) || empty($credentials["jwt"])) {
            throw new \Exception("JWT is required");
        }

        // Make sure we have a secret key to decode the JWT
        if(!array_key_exists("secret_key", $credentials) || empty($credentials["secret_key"])) {
            throw new \Exception("Secret Key is required to decode this JWT");
        }

        // Get hash alg from params, default to HS256
        $hashAlgs = array("HS256");
        if(array_key_exists("hash_alg", $credentials) && !empty($credentials["hash_alg"])) {
            $hashAlgs[] = $credentials["hash_alg"];
            $hashAlgs = array_unique($hashAlgs);
        }

        $token = JWT::decode($credentials["jwt"], $credentials["secret_key"], $hashAlgs);

        // User ID is a good checksum to make sure we have a valid JWT
        if(empty($token) || empty($token->id)) {
            throw new \Exception("JWT Token invalid");
        }

        return $token;
    }
991422
protected function validateUser(array $credentials, $id = null)
    {
        $instance = $this->createModel();

        $loginNames = $instance->getLoginNames();

        // We will simply parse credentials which checks logins and passwords
        list($logins, $password, $credentials) = $this->parseCredentials($credentials, $loginNames);

        if ($id === null) {
            if (empty($logins)) {
                throw new InvalidArgumentException('No [login] credential was passed.');
            }

            if (empty($password)) {
                throw new InvalidArgumentException('You have not passed a [password].');
            }
        }

        return true;
    }
962895
protected function sendRequest(array $credentials): ResponseInterface
    {
        $options = [
            ('GET' === $this->requestMethod) ? 'query' : 'json' => $credentials,
        ];

        return $this->setHttpClient($this->app['http_client'])->request($this->getEndpoint(), $this->requestMethod, $options);
    }
1173633
public function create(array $credentials)
	{
		$user = $this->createModel();
		$user->fill($credentials);
		$user->save();

		return $user;
	}
922301
protected function validate(array $credentials, $id = null)
    {
        if ($id !== null)
        {
            return true;
        }

        if (count(array_only($credentials, ['password', 'email', 'username'])) < 3)
        {
            return false;
        }

        return true;
    }
1234641
public function registerGuest(array $credentials)
    {
        $user = $this->findGuestUserByCredentials($credentials);
        $newUser = false;

        if (!$user) {
            $user = $this->createUserModel();
            $newUser = true;
        }

        $user->fill($credentials);
        $user->is_guest = true;
        $user->save();

        // Add user to guest group
        if ($newUser && $group = UserGroupModel::getGuestGroup()) {
            $user->groups()->add($group);
        }

        // Prevents revalidation of the password field
        // on subsequent saves to this model object
        $user->password = null;

        return $this->user = $user;
    }
481632
protected function getPasswordCredential($credentials = array())
	{
		$passField = $this->app['config']['auth.credentials.password'];

		if (isset($credentials[$passField]))
		{
			return $credentials[$passField];
		}
		else if (Input::has($passField))
		{
			return Input::get($passField);
		}
		else if (isset($credentials['user_password']))
		{
			return $credentials['user_password'];
		}
		else if (isset($credentials['pwd']))
		{
			return $credentials['pwd'];
		}

		throw new InvalidArgumentException("Password field not found");

	}
677976
public function retrieveByCredentials(array $credentials)
    {
        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // generic "user" object that will be utilized by the Guard instances.
        $query = array();
        $coll = $this->conn->{$this->table};

        foreach ($credentials as $key => $value)
        {
            if ( ! str_contains($key, 'password'))
            {
                $query[$key] = $value;
            }
        }

        // Now we are ready to execute the query to see if we have an user matching
        // the given credentials. If not, we will just return nulls and indicate
        // that there are no matching users for these given credential arrays.
        $user = $coll->findOne($query);

        if ( ! is_null($user))
        {
            return new MongolUser((array) $user);
        }
    }
999955
public function verify(array $credentials, Closure $callback)
    {
        // If the responses from the validate method is not a user instance, we will
        // assume that it is a redirect and simply return it from this method and
        // the user is properly redirected having an error message on the post.
        $user = $this->validateEmailVerification($credentials);

        if (! $user instanceof CanVerifyEmailContract) {
            return $user;
        }

        if($callback($user)) {

            $this->events->dispatch(new UserVerified($user));

        }

        return static::VERIFIED;
    }
589676
public function validateCredentials(UserContract $user, array $credentials)
    {

        $password = $credentials['password'];
        $username = array_key_exists('username', $credentials) ? $credentials['username'] : $this->model->whereEmail($credentials['email'])->FirstOrFail()->username;

        return $this->hasher->check(compact('username', 'password'), $user->getAuthPassword());
    }
175974
public function validateCredentials(UserContract $user, array $credentials)
    {
        $credentialsValidated = false;

        // If the user is set AND, either of auth_type 'internal' or with
        // auth_type unset or null, then validate against the stored
        // password hash. Otherwise if the LDAP authentication
        // method is enabled, try it.
        if ( isset($user) &&
             (
                ( isset($user->auth_type) && (Settings::get('eloquent-ldap.label_internal') === $user->auth_type) ) ||
                ( !isset($user->auth_type) )
             )
           ) {
            $plain = $credentials['password'];
            $credentialsValidated = $this->hasher->check($plain, $user->getAuthPassword());
        } else if ( (Settings::get('eloquent-ldap.enabled')) && (Settings::get('eloquent-ldap.label_ldap') === $user->auth_type) ) {
            // Validate credentials against LDAP/AD server.
            $credentialsValidated = $this->validateLDAPCredentials($credentials);
            // If validated and config set to resync group membership on login.
            if ( $credentialsValidated ) {
                // Sync user enable/disable state
                $this->syncEnable($user);
                if ( (Settings::get('eloquent-ldap.resync_on_login')) && (Settings::get('eloquent-ldap.replicate_group_membership'))) {
                    // First, revoke membership to all groups marked to 'resync_on_login'.
                    $this->revokeMembership($user);
                    // Then replicate group membership.
                    $this->replicateMembershipFromLDAP($user);
                }
            }
         }

        return $credentialsValidated;
    }
148555
public function authenticate(array $credentials)
    {

        // Dirty hack so we can use in both User->Authenticator->authenticate() and \Nette\Security\User->login() methods
        // arrays with named keys instead of anonymous arrays.
        // Eg. $userAuthenticator->authenticate(['username' => $username, 'alwaysLogin' => true]); instead of
        // $userAuthenticator->authenticate([$username, null, null, null, true]);
        if (count($credentials) == 1 && isset($credentials[0]) && is_array($credentials[0])) {
            $credentials = $credentials[0];
        }

        $user = false;
        $source = null;
        $regenerateToken = null;
        $exception = null;
        $authenticators = $this->authenticatorManager->getAuthenticators();
        /** @var AuthenticatorInterface $authenticator */
        foreach ($authenticators as $authenticator) {
            try {
                $u = $authenticator->setCredentials($credentials)->authenticate();

                $regenerateToken = $authenticator->shouldRegenerateToken();

                if ($u !== null && $u !== false) {
                    $user = $u;
                    $source = $authenticator->getSource();
                    break;
                }
            } catch (RateLimitException $e) {
                $exception = $e;
                break;
            } catch (AuthenticationException $e) {
                if ($exception === null) {
                    $exception = $e;
                }
                continue;
            }
        }

        if ($user === false && $exception !== null) {
            throw $exception;
        }
        if ($user === false) {
            throw new AuthenticationException('', UserAuthenticator::IDENTITY_NOT_FOUND);
        }
        $this->emitter->emit(new UserSignInEvent($user, $source, $regenerateToken ?? true));

        $arr = $user->toArray();
        unset($arr[self::COLUMN_PASSWORD_HASH]);

        $groups = [];
        if ($user['role'] === UsersRepository::ROLE_ADMIN) {
            $userGroups = $user->related('admin_user_groups');
            foreach ($userGroups as $userGroup) {
                $groups[] = $userGroup->admin_group->name;
            }
        }

        return new Identity($user['id'], $groups, $arr);
    }