class LoginService implements LoggerAwareInterface, ApplicationAwareInterface (View source)

Traits

Trait LoggerAwareTrait A trait used with LoggerAwareInterface

Trait ApplicationAwareTrait A trait used with ApplicationAwareInterface

LoggerAwareTrait

Properties

protected Application $app from  ApplicationAwareTrait
protected Repository $config

The config repository we use to format errors appropriately

protected LoginAttemptService $loginAttemptService

This service tracks login attempts and deals with excessive attempts

protected string deprecated $userClass

The class to use when testing login credentials.

protected IPService $ipService

This service tracks login attempts against IPs and deals with excessive attempts from specific IPs

protected EntityManagerInterface|null $entityManager

The entity manager to use to find out more information about a login attempt

protected Request|null $request

The request instance

Methods

getLoggerChannel()

Get the logger channel expected by this LoggerAwareTrait implementation The user is expected to declare this method and return a valid channel name.

setApplication(Application $app)

Setter method for the application

__construct(Repository $config, LoginAttemptService $loginAttemptService, IPService $IPService, EntityManagerInterface $entityManager = null, Request $request = null)

No description

login(string $username, string $password)

Attempt login given a username and a password

loginByUserID(int $userId)

Force log in as a specific user ID This method will setup session and set a cookie

failLogin(string $username, string $password)

Handle a failed login attempt

logLoginAttempt($username, array $errors = [])

Add a log entry for this login attempt

array
getGroups($username)

Aggregate a list of groups to report

handleUserError(int $errorNum)

Throw an exception based on the given error number

setUserClass(string $userClass) deprecated

Change the user class used to validate the given credentials

Details

getLoggerChannel()

Get the logger channel expected by this LoggerAwareTrait implementation The user is expected to declare this method and return a valid channel name.

setApplication(Application $app)

Setter method for the application

Parameters

Application $app

__construct(Repository $config, LoginAttemptService $loginAttemptService, IPService $IPService, EntityManagerInterface $entityManager = null, Request $request = null)

No description

Parameters

Repository $config
LoginAttemptService $loginAttemptService
IPService $IPService
EntityManagerInterface $entityManager
Request $request

User login(string $username, string $password)

Attempt login given a username and a password

Parameters

string $username

The username or email to attempt login with

string $password

The plain text password to attempt login with

Return Value

User

The logged in user

Exceptions

NotActiveException
InvalidCredentialsException
NotValidatedException
SessionExpiredException

User loginByUserID(int $userId)

Force log in as a specific user ID This method will setup session and set a cookie

Parameters

int $userId

The user id to login as

Return Value

User

The newly logged in user

failLogin(string $username, string $password)

Handle a failed login attempt

Parameters

string $username

The user provided username

string $password

The user provided password

Exceptions

FailedLoginThresholdExceededException

logLoginAttempt($username, array $errors = [])

Add a log entry for this login attempt

Parameters

$username
array $errors

private array getGroups($username)

Aggregate a list of groups to report

Parameters

$username

Return Value

array

protected handleUserError(int $errorNum)

Throw an exception based on the given error number

Parameters

int $errorNum

The error number retrieved from the user object

Exceptions

RuntimeException
NotActiveException
InvalidCredentialsException
NotValidatedException
SessionExpiredException

setUserClass(string $userClass) deprecated

deprecated This will be removed once the User class is no longer in charge of negotiating login ~9.0

Change the user class used to validate the given credentials

Parameters

string $userClass