API UserManager - chsxf/mfx GitHub Wiki
UserManager Class
final class UserManager implements Services\IAuthenticationService
Summary
User management class
Since 2.0
Methods
__construct
public function __construct(Services\IConfigService $configService, Services\IDatabaseService $databaseService, Services\ISessionService $sessionService)
Constructor
Since 2.0
Parameters
Name | Type | Description |
---|---|---|
$configService |
IConfigService |
Config service instance |
$databaseService |
IDatabaseService |
Database service instance |
$sessionService |
ISessionService |
Session service instance |
getCurrentAuthenticatedUser
public function getCurrentAuthenticatedUser(): ?User
Gets the current user reference
Since 2.0
Returns
User
getIdField
public function getIdField(): string
Retrieves users management identifier field name
Since 2.0
Returns
string
Throws
Exception | Reason |
---|---|
MFXException |
If the provided value is not a string or contains invalid characters (only underscores and alphanumeric characters are accepted) |
getTableName
public function getTableName(): string
Retrieves users management table name
Since 2.0
Returns
string
Throws
Exception | Reason |
---|---|
MFXException |
If the provided value is not a string or contains invalid characters (only underscores and alphanumeric characters are accepted) |
hasAuthenticatedUser
public function hasAuthenticatedUser(): bool
Tells if an authenticated user currently exists
Since 2.0
Returns
bool
invalidate
public function invalidate()
Invalidates user session. Logs out the current valid user if existing
Since 2.0
isEnabled
public function isEnabled(): bool
Tells if user management is enabled
Since 2.0
Returns
bool
validateWithFields
public function validateWithFields(array $fields): bool
Validates a user session using database fields
Since 2.0
Parameters
Name | Type | Description |
---|---|---|
$fields |
array |
Key-value pairs for database validation |
Returns
boolean
true if the session has been validated, false either