Performs an authentication.
@param array $credentials
@return Nette\Security\Identity
@throws Nette\Security\AuthenticationException
164717
public function authenticate(array $credentials)
	{
		list($email, $password) = $credentials;

		/** @var ActiveRow $row */
		$row = $this->model->getTableSelection()->where(self::COLUMN_NAME, $email)->fetch();

		if (!$row || !Passwords::verify($password, $row[self::COLUMN_PASSWORD_HASH])) {
			throw new Nette\Security\AuthenticationException('Špatné přihlašovací údaje', self::INVALID_CREDENTIAL);
		} elseif (Passwords::needsRehash($row[self::COLUMN_PASSWORD_HASH])) {
			$row->update(array(
				self::COLUMN_PASSWORD_HASH => Passwords::hash($password),
			));
		}

		$arr    = $row->toArray();
		$rules = json_decode($arr['rules'], true);

		unset($arr[self::COLUMN_PASSWORD_HASH], $arr['rules'], $arr[self::COLUMN_ROLE]);
		return new Nette\Security\Identity($row[self::COLUMN_ID], array_merge([$row[self::COLUMN_ROLE]], $rules), $arr);
	}
1010605
private function processAuthentication(array $credentials)
    {
        /** @var \Ma27\ApiKeyAuthenticationBundle\Service\Auth\AuthenticationHandlerInterface $authenticationHandler */
        $authenticationHandler = $this->get('ma27_api_key_authentication.auth_handler');
        /** @var \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */
        $dispatcher = $this->get('event_dispatcher');

        try {
            $user = $authenticationHandler->authenticate($credentials);
        } catch (CredentialException $ex) {
            $userOrNull = $user ?? null;
            $dispatcher->dispatch(
                Ma27ApiKeyAuthenticationEvents::CREDENTIAL_EXCEPTION_THROWN,
                new OnCredentialExceptionThrownEvent($ex, $userOrNull)
            );

            return [$userOrNull, $ex];
        }

        return [$user, null];
    }
181056
public function setCredentials(array $credentials) : AuthenticatorInterface
    {
        if (array_key_exists('source', $credentials) && preg_match('/^api*/', $credentials['source'])) {
            $this->api = true;
            $this->source = $credentials['source'];
        }

        return $this;
    }
636100
public function validate(array $credentials = [])
    {
        $this->lastAttempted = $user = $this->provider->retrieveByCredentials($credentials);

        return $this->hasValidCredentials($user, $credentials);
    }
955984
public function retrieveByCredentials(array $credentials): ?UserContract
    {
        $name = Authen::getIdentifierName();

        if (! isset($credentials[$name]) || empty($credentials[$name])) {
            return parent::retrieveByCredentials($credentials);
        }

        $identifier = $credentials[$name];
        unset($credentials[$name]);

        // 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
        // Eloquent User "model" that will be utilized by the Guard instances.

        $query = $this->createModel()
                    ->newQuery()
                    ->findByIdentifiers($identifier);

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

        return $query->first();
    }
20138
protected function createUser(array $credentials)
    {
        $entity = static::ENTITY_CLASSNAME;

        if (count(array_only($credentials, ['email', 'password', 'username'])) < 3)
        {
            throw new \InvalidArgumentException("Missing arguments.");
        }

        /** @var User $user */
        $user = new $entity(
            $credentials['email'],
            $credentials['password'],
            $credentials['username']
        );

        $rest = array_except($credentials, ['email', 'username', 'password']);
        if (! empty($rest))
        {
            $user->update($rest);
        }

        return $user;
    }
757837
public static function handler(array $credentials = array()) {

		$calendar_guid = elgg_extract('calendar_guid', $credentials);
		$user_guid = elgg_extract('user_guid', $credentials);
		$token = elgg_extract('token', $credentials);

		$ia = elgg_set_ignore_access(true);
		$calendar = get_entity($calendar_guid);
		$user = get_entity($user_guid);
		elgg_set_ignore_access($ia);

		$pam = new PAM($calendar, $user);

		if (!has_access_to_entity($calendar, $user)) {
			throw new LoginException('User does not have access to this calendar');
		}

		if (!$calendar->getToken()) {
			throw new LoginException('Calendar does not allow remote access');
		}

		if (!$pam->validateToken($token)) {
			throw new LoginException('Invalid token');
		}

		return true;
	}
386232
public function retrieveByCredentials(array $credentials)
    {
        $criteria = [];
        foreach ($credentials as $key => $value) {
            if (!str_contains($key, 'password')) {
                $criteria[$key] = $value;
            }
        }

        return $this->getRepository()->findOneBy($criteria);
    }
425209
public static function authenticate(array $credentials, $remember = false, $login = true, $appId = null)
    {
        if (\Auth::attempt($credentials)) {
            $user = \Auth::getLastAttempted();
            /** @noinspection PhpUndefinedFieldInspection */
            static::checkRole($user->id);
            if ($login) {
                /** @noinspection PhpUndefinedFieldInspection */
                $user->last_login_date = Carbon::now()->toDateTimeString();
                /** @noinspection PhpUndefinedFieldInspection */
                $user->confirm_code = 'y';
                /** @noinspection PhpUndefinedMethodInspection */
                $user->save();
                /** @noinspection PhpParamsInspection */
                Session::setUserInfoWithJWT($user, $remember, $appId);
            }

            return true;
        } else {
            return false;
        }
    }
359232
public function attempt(array $credentials)
    {
        if (! $this->auth->byCredentials($credentials)) {
            return false;
        }

        return $this->fromUser($this->user());
    }
1267708
public function create(array $credentials)
	{
		if ( ! isset($credentials['permissions']) )
		{
			$credentials['permissions'] = array();
		}

		$user = $this->createModel();
		$user->values($credentials);
		$user->save();

		return $user;
	}
947808
public function retrieveByCredentials(array $credentials)
    {
        $criteria = [];
        foreach ($credentials as $key => $value) {
            if (!Str::contains($key, 'password')) {
                $criteria[$key] = $value;
            }
        }

        return $this->getRepository()->findOneBy($criteria);
    }
1100656
protected function validateReset(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

        if (! $this->validateNewPassword($credentials)) {
            return static::INVALID_PASSWORD;
        }

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

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

        return $user;
    }
1114993
public function authenticate(array $credentials)
    {
        $loginProperty = $this->classMetadata->getPropertyName(ClassMetadata::LOGIN_PROPERTY);
        $passwordProperty = $this->classMetadata->getPropertyName(ClassMetadata::PASSWORD_PROPERTY);

        if (!array_key_exists($passwordProperty, $credentials)) {
            throw new \InvalidArgumentException(sprintf(
                'Unable to find password property "%s" in credential set!',
                $passwordProperty
            ));
        }

        if (!array_key_exists($loginProperty, $credentials)) {
            throw new \InvalidArgumentException(sprintf(
                'Unable to find login property "%s" in credential set!',
                $loginProperty
            ));
        }

        $object = $this->resolveObject($loginProperty, $credentials);

        if (!$this->validateCredentials($object, $credentials[$passwordProperty])) {
            $this->eventDispatcher->dispatch(
                Ma27ApiKeyAuthenticationEvents::CREDENTIAL_FAILURE,
                new OnInvalidCredentialsEvent($object)
            );

            throw new CredentialException();
        }

        $this->eventDispatcher->dispatch(Ma27ApiKeyAuthenticationEvents::AUTHENTICATION, new OnAuthenticationEvent($object));
        $this->buildKey($object);

        $this->om->persist($object);
        $this->om->flush();

        return $object;
    }
1071679
public function findByCredentials(array $credentials)
    {
        $queryBuilder = $this->createQueryBuilder('u');

        $this->createCredentialsCriteria($queryBuilder, $credentials);

        $queryBuilder->setMaxResults(1);

        return $queryBuilder->getQuery()->getOneOrNullResult();
    }
734958
public function authentication(Request $request, array $credentials)
    {
        if (isset($credentials['username'], $credentials['password'])) {
            $value = $this->_generateHeader($credentials['username'], $credentials['password']);
            $request = $request->withHeader('Authorization', $value);
        }

        return $request;
    }
1229271
public function attempt(array $credentials) {
    $user = $this->users->retrieveByCredentials($credentials);

    if($user instanceof UserInterface && $this->users->validateCredentials($user, $credentials)) {
       return $this->create($user);
    }

    return false;
  }