final class LoginResult

Immutable result of a login attempt. Carries the outcome as a status constant plus, where relevant, the user the attempt concerned. Lets the login policy (LoginService) decide the outcome while the caller (controller) owns the resulting HTTP behavior — redirects, flash messages — rather than those being fired from inside the service.

Constants

SUCCESS

Credentials were valid and the user was logged in.

NEEDS_RESET

Credentials were valid but the account is flagged for password reset.

INACTIVE

Credentials were valid but the account is inactive.

LOCKED

Credentials were invalid and the account is now locked.

INVALID

Credentials were invalid (wrong password or unknown user).

Methods

__construct(string $status, Principal|null $user = null)

No description

static LoginResult
inactive()

Returns new instance with status set to self::INACTIVE.

static LoginResult
invalid()

Returns new instance with status set to self::INVALID.

static LoginResult
locked()

Returns new instance with status set to self::LOCKED.

static LoginResult
needsReset(Principal $user)

Returns new instance with status set to self::NEEDS_RESET.

bool
succeeded()

Determines if attempt is successful.

static LoginResult
success(Principal $user)

Returns new instance with status set to self::SUCCESS.

Details

at line 30
private __construct(string $status, Principal|null $user = null)

No description

Parameters

string $status

One of the status constants above.

Principal|null $user

The user the attempt concerned, when known.

at line 40
static LoginResult inactive()

Returns new instance with status set to self::INACTIVE.

Return Value

LoginResult

at line 49
static LoginResult invalid()

Returns new instance with status set to self::INVALID.

Return Value

LoginResult

at line 58
static LoginResult locked()

Returns new instance with status set to self::LOCKED.

Return Value

LoginResult

at line 68
static LoginResult needsReset(Principal $user)

Returns new instance with status set to self::NEEDS_RESET.

Parameters

Principal $user

The user whose account requires a password reset.

Return Value

LoginResult

at line 77
bool succeeded()

Determines if attempt is successful.

Return Value

bool

True if the attempt succeeded.

at line 87
static LoginResult success(Principal $user)

Returns new instance with status set to self::SUCCESS.

Parameters

Principal $user

The successfully authenticated user.

Return Value

LoginResult