User
From Utopia MVC
User Session Management class, handles login/logout, provides tools to register new users, and manages the user data during the session.
In future it might implement autologin using cookies.
All public methods are static (with the exception of the __get magic method), and the class is supposed to be used as singleton.
Contents |
Attributes
m_pInstance
[toc]
private static User $m_pInstanceHolds statically the current User object allowing this class to be used as singleton.
groups
[toc]
public array $groupsThe list of groups (strings) the User belongs to.
isGuest
[toc]
public boolean $isGuest=trueFlag identifying non-logged users.
isTemp
[toc]
public boolean $isTemp=falseFlag identifying users logged with temporary passwords.
username
[toc]
public string $usernameThe Username of the logged user.
ID
[toc]
public int $IDThe numeric ID of the logged user.
moreData
[toc]
private array $moreDataArray used to store all the values retrieved from the user database table and possibly other sources, the values are retrieved through the magic method __get, accessing User::someRandomValue will return User::moreData['someRandomValue'] instead.
salt
[toc]
private string $saltUsed for salting the passwords, to obtain a hashed password use the hashPassword method.
tableName
[toc]
private string $tableNameusernameColumn
[toc]
private string $usernameColumnpasswordColumn
[toc]
private string $passwordColumntempPasswordColumn
[toc]
private string $tempPasswordColumntableStructure
[toc]
private array $tableStructureAlong with the previous attributes describe the database storage structure.
Methods
getInstance
Factory method
Creates the singleton instance if it didn't exist yet and returns it.
Returns the singleton User instance.
__construct
Default constructor, using User::getInstance is recommended.
Inizialization of the class, attempts to logout if $_GET['action']=='logout' or starts the session if not, also loads configuration values for the class from configurations/User.class.xml.
__get
Magic method retrieving generic values.
When loading the User data from the database all the fields are stored in both the specific attributes and the $moreData array, this method returns those values by transforming User::someRandomValue into User::moreData['someRandomValue'].
- name
- the name of the attribute requested.
The content of the attribute requested.