src/Service.php
public function login(ServerRequestInterface $request, ?Adapter $adapter = null): bool
    {
        $started = $this->session->resume() || $this->session->start();
        if (!$started) {
            return false;
        }

        $login = $adapter ?? $this->adapter;
        if ($login === null) {
            throw new \InvalidArgumentException('You must specify an adapter for authentication');
        }
        $this->principal = $principal = $login->login($request);

        $this->session->clear();
        $this->session->regenerateId();

        $this->values->offsetSet('principal', $principal);
        $now = microtime(true);
        $this->values->offsetSet('firstActive', $now);
        $this->values->offsetSet('lastActive', $now);

        $this->logger->info(
            "Authentication login: {user}",
            ['user' => $principal]
        );
        return $this->publishLogin($principal);
    }
public function login(ServerRequestInterface $request, ?Adapter $adapter = null): bool
    {
        $started = $this->session->resume() || $this->session->start();
        if (!$started) {
            return false;
        }

        $login = $adapter ?? $this->adapter;
        if ($login === null) {
            throw new \InvalidArgumentException('You must specify an adapter for authentication');
        }
        $this->principal = $principal = $login->login($request);

        $this->session->clear();
        $this->session->regenerateId();

        $this->values->offsetSet('principal', $principal);
        $now = microtime(true);
        $this->values->offsetSet('firstActive', $now);
        $this->values->offsetSet('lastActive', $now);

        $this->logger->info(
            "Authentication login: {user}",
            ['user' => $principal]
        );
        return $this->publishLogin($principal);
    }
public function login ( ServerRequestInterface $ request , ? Adapter $ adapter = null ) : bool { $ started = $ this -> session -> resume ( ) || $ this -> session -> start ( ) ; if ( ! $ started ) { return false ; } $ login = $ adapter ?? $ this -> adapter ; if ( $ login === null ) { throw new \ InvalidArgumentException ( 'You must specify an adapter for authentication' ) ; } $ this -> principal = $ principal = $ login -> login ( $ request ) ; $ this -> session -> clear ( ) ; $ this -> session -> regenerateId ( ) ; $ this -> values -> offsetSet ( 'principal' , $ principal ) ; $ now = microtime ( true ) ; $ this -> values -> offsetSet ( 'firstActive' , $ now ) ; $ this -> values -> offsetSet ( 'lastActive' , $ now ) ; $ this -> logger -> info ( "Authentication login: {user}" , [ 'user' => $ principal ] ) ; return $ this -> publishLogin ( $ principal ) ; }
Authenticates a principal.

@param ServerRequestInterface $request The Server Request message containing credentials
@param Adapter|null $adapter An optional adapter to use.
Will use the default authentication adapter if none is specified.
@return bool Whether the session could be established
@throws \InvalidArgumentException If no adapter is provided and no default adapter is set
@throws Exception\UsernameNotFound if the provided username wasn't found
@throws Exception\UsernameAmbiguous if the provided username matches multiple accounts
@throws Exception\InvalidPassword if the provided password is invalid
@throws Exception\ConnectionFailed if the access to a remote data source failed
(e.g. missing flat file, unreachable LDAP server, database login denied)
Authenticates a principal .