Class TUserManager
TUserManager class
TUserManager manages a static list of users TUser
. The user
information is specified via module configuration using the following XML
syntax,
<module id="users" class="System.Security.TUserManager" PasswordMode="Clear"> <user name="Joe" password="demo" /> <user name="John" password="demo" /> <role name="Administrator" users="John" /> <role name="Writer" users="Joe,John" /> </module>
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 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 setPasswordMode PasswordMode as Clear, SHA1 or MD5. The default name for a guest user is Guest. It may be changed by setting setGuestName GuestName property.
TUserManager may be used together with TAuthManager
which manages how
users are authenticated and authorized in a Prado application.
- TComponent
-
TApplicationComponent
-
TModule implements IModule
-
TUserManager implements IUserManager
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Author: Carl Mathisen <carl@kamikazemedia.no>
Since: 3.0
Located at Security/TUserManager.php
public
|
#
init( mixed $config )
Initializes the module. This method is required by IModule and is invoked by application. It loads user/role information from the module configuration. |
public
array
|
#
getUsers( )
Returns an array of all users. 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. |
public
array
|
#
getRoles( )
Returns an array of user role information. 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. |
public
string
|
|
public
|
|
public
string
|
|
public
|
|
public
|
|
public
|
|
public
boolean
|
#
validateUser( string $username, string $password )
Validates if the username and password are correct. |
public
|
|
public
|
#
getUserFromCookie(
Returns a user instance according to auth data stored in a cookie. |
public
|
|
public
|
getID(),
setID()
|
getApplication(),
getRequest(),
getResponse(),
getService(),
getSession(),
publishAsset(),
publishFilePath()
|
string |
USER_FILE_EXT |
'.xml' |
#
extension name to the user file |
GLOBAL_RAISE_EVENT_LISTENER
|