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
bool
activateUser(string $token)

Activates a user based on the provided action 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

int|true
authenticate(int|string $identifier, string|null $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.

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

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

int|true
forceLogin(int|string $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 48
setUserRepository(UserRepositoryInterface $userRepository)

Sets the user repository.

Parameters

UserRepositoryInterface $userRepository User repository

in Adapter at line 22
UserRepository getUserRepository()

Return Value

UserRepository

in Adapter at line 64
setGroupRepository(GroupRepositoryInterface $groupRepository)

Sets the group repository.

Parameters

GroupRepositoryInterface $groupRepository Group repository

in Adapter at line 22
GroupRepository getGroupRepository()

Return Value

GroupRepository

in Adapter at line 80
setUser(UserEntityInterface $user)

Sets the active user.

Parameters

UserEntityInterface $user User entity

in Adapter at line 88
bool isGuest()

Returns TRUE if we don't have an authenticated user and FALSE if we do.

Return Value

bool

in Adapter at line 96
bool isLoggedIn()

Returns TRUE if we have an authenticated user and FALSE if we don't.

Return Value

bool

at line 116
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 131
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 147
bool activateUser(string $token)

Activates a user based on the provided action token.

Parameters

string $token Action token

Return Value

bool

at line 90
__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 108
string getName()

Returns the adapter name.

Return Value

string

at line 27
User|null getUser()

Return Value

User|null

at line 174
protected int|true authenticate(int|string $identifier, string|null $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

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

Return Value

int|true

at line 221
protected setRememberMeCookie()

Sets a remember me cookie.

at line 242
int|true login(int|string $identifier, string|null $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

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

Return Value

int|true

at line 279
int|true forceLogin(int|string $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

int|string $identifier User identifier
bool $remember Set a remember me cookie?

Return Value

int|true

at line 290
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 312
logout()

Logs the user out.