PHP Class Prado\Security\TUserManager
TUserManager manages a static list of users {@link TUser}.
The user information is specified via module configuration using the following XML syntax,
PHP configuration style:
array(
'users' => array(
'class' => 'System.Security.TUserManager',
'properties' => array(
'PasswordMode' => 'Clear',
),
'users' => array(
array('name'=>'Joe','password'=>'demo'),
array('name'=>'John','password'=>'demo'),
),
'roles' => array(
array('name'=>'Administrator','users'=>'John'),
array('name'=>'Writer','users'=>'Joe,John'),
),
),
)
In addition, user information can also be loaded from an external file
specified by {@link setUserFile UserFile} property. Note, the property
only accepts a file path in namespace format. The user file format is
similar to the above sample.
The user passwords may be specified as clear text, SH1 or MD5 hashed by setting
{@link setPasswordMode PasswordMode} as
Clear,
SHA1 or
MD5.
The default name for a guest user is
Guest. It may be changed
by setting {@link setGuestName GuestName} property.
TUserManager may be used together with {@link TAuthManager} which manages
how users are authenticated and authorized in a Prado application.
Afficher le fichier
Open project: pradosoft/prado
Class Usage Examples
Méthodes publiques
Private Methods
Method Details
getGuestName()
public méthode
getPasswordMode()
public méthode
public getPasswordMode ( ) : TUserManagerPasswordMode |
Résultat |
TUserManagerPasswordMode |
how password is stored, clear text, or MD5 or SHA1 hashed. Default to TUserManagerPasswordMode::MD5. |
getRoles()
public méthode
Each array element represents the roles for a single user.
The array key is the username in lower case, and the array value is
the roles (represented as an array) that the user is in.
Returns a user instance given the user name.
public getUser ( $username = null ) : TUser |
Résultat |
TUser |
the user instance, null if the specified username is not in the user database. |
getUserFile()
public méthode
getUserFromCookie()
public méthode
Returns a user instance according to auth data stored in a cookie.
public getUserFromCookie ( $cookie ) : TUser |
Résultat |
TUser |
the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data. |
getUsers()
public méthode
Each array element represents a single user.
The array key is the username in lower case, and the array value is the
corresponding user password.
This method is required by IModule and is invoked by application.
It loads user/role information from the module configuration.
saveUserToCookie()
public méthode
Saves user auth data into a cookie.
setGuestName()
public méthode
setPasswordMode()
public méthode
setUserFile()
public méthode
switchToGuest()
public méthode
User name is changed as guest name, and roles are emptied.
validateUser()
public méthode
Validates if the username and password are correct.