class Session extends Adapter

Session adapter.

Properties

protected UserRepository $userRepository User repository. from Adapter
protected GroupRepository $groupRepository Group repository. from Adapter
protected User|null $user User entity. from Adapter
protected Request $request Request instance.
protected Response $response Response instance.
protected Session $session Session instance.
protected array $options Adapter options.
protected bool $hasLoggedOut Has the user logged out?

Methods

setUserRepository(UserRepositoryInterface $userRepository)

Sets the user repository.

from Adapter
getUserRepository()

No description

from Adapter
setGroupRepository(GroupRepositoryInterface $groupRepository)

Sets the group repository.

from Adapter
getGroupRepository()

No description

from Adapter
setUser(UserEntityInterface $user)

Sets the active user.

from Adapter
bool
isGuest()

Returns true if we don't have an authenticated user and false if we do.

from Adapter
bool
isLoggedIn()

Returns true if we have an authenticated user and false if we don't.

from Adapter
createUser(string $email, string $username, string $password, bool $activate = false, array $properties = [])

Creates a new user and returns the user object.

createGroup(string $name, array $properties = [])

Creates a new group and returns the group object.

from Adapter
User|bool
activateUser(string $token)

Activates a user based on the provided auth token.

from Adapter
__construct(UserRepository $userRepository, GroupRepository $groupRepository, Request $request, Response $response, Session $session, array $options = [])

Constructor.

string
getName()

Returns the adapter name.

User|null
getUser()

No description

bool|int
authenticate(string $identifier, string $password, bool $force = false)

Returns true if the identifier + password combination matches and the user is activated, not locked and not banned.

setRememberMeCookie()

Sets a remember me cookie.

bool|int
login(string $identifier, string $password, bool $remember = false, bool $force = false)

Logs in a user with a valid identifier/password combination.

bool|int
forceLogin(mixed $identifier, bool $remember = false)

Login a user without checking the password.

bool
basicAuth(bool $clearResponse = false)

Returns a basic authentication response if login is required and null if not.

logout()

Logs the user out.

Details

in Adapter at line 50
setUserRepository(UserRepositoryInterface $userRepository)

Sets the user repository.

Parameters

UserRepositoryInterface $userRepository User repository

in Adapter at line 24
UserRepository getUserRepository()

Return Value

UserRepository

in Adapter at line 66
setGroupRepository(GroupRepositoryInterface $groupRepository)

Sets the group repository.

Parameters

GroupRepositoryInterface $groupRepository Group repository

in Adapter at line 24
GroupRepository getGroupRepository()

Return Value

GroupRepository

in Adapter at line 82
setUser(UserEntityInterface $user)

Sets the active user.

Parameters

UserEntityInterface $user User entity

in Adapter at line 90
bool isGuest()

Returns true if we don't have an authenticated user and false if we do.

Return Value

bool

in Adapter at line 98
bool isLoggedIn()

Returns true if we have an authenticated user and false if we don't.

Return Value

bool

at line 118
User createUser(string $email, string $username, string $password, bool $activate = false, array $properties = [])

Creates a new user and returns the user object.

Parameters

string $email Email address
string $username Username
string $password Password
bool $activate Will activate the user if set to true
array $properties Additional user properties

Return Value

User

in Adapter at line 133
Group createGroup(string $name, array $properties = [])

Creates a new group and returns the group object.

Parameters

string $name Group name
array $properties Additional group properties

Return Value

Group

in Adapter at line 149
User|bool activateUser(string $token)

Activates a user based on the provided auth token.

Parameters

string $token Auth token

Return Value

User|bool

at line 92
__construct(UserRepository $userRepository, GroupRepository $groupRepository, Request $request, Response $response, Session $session, array $options = [])

Constructor.

Parameters

UserRepository $userRepository User repository
GroupRepository $groupRepository Group repository
Request $request Request instance
Response $response Response instance
Session $session Session instance
array $options Options

at line 110
string getName()

Returns the adapter name.

Return Value

string

at line 29
User|null getUser()

Return Value

User|null

at line 176
protected bool|int authenticate(string $identifier, string $password, bool $force = false)

Returns true if the identifier + password combination matches and the user is activated, not locked and not banned.

A status code will be retured in all other situations.

Parameters

string $identifier User email or username
string $password User password
bool $force Skip the password check?

Return Value

bool|int

at line 225
protected setRememberMeCookie()

Sets a remember me cookie.

Exceptions

RuntimeException

at line 246
bool|int login(string $identifier, string $password, bool $remember = false, bool $force = false)

Logs in a user with a valid identifier/password combination.

Returns true if the identifier + password combination matches and the user is activated, not locked and not banned. A status code will be retured in all other situations.

Parameters

string $identifier User identifier
string $password User password
bool $remember Set a remember me cookie?
bool $force Login the user without checking the password?

Return Value

bool|int

at line 283
bool|int forceLogin(mixed $identifier, bool $remember = false)

Login a user without checking the password.

Returns true if the identifier exists and the user is activated, not locked and not banned. A status code will be retured in all other situations.

Parameters

mixed $identifier User identifier
bool $remember Set a remember me cookie?

Return Value

bool|int

at line 294
bool basicAuth(bool $clearResponse = false)

Returns a basic authentication response if login is required and null if not.

Parameters

bool $clearResponse Clear all previously set headers and cookies from the response?

Return Value

bool

at line 316
logout()

Logs the user out.