PHP Класс 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.
Показать файл
Открыть проект
Примеры использования класса
Открытые методы
Приватные методы
Описание методов
getGuestName()
публичный метод
getPasswordMode()
публичный метод
public getPasswordMode ( ) : TUserManagerPasswordMode |
Результат |
TUserManagerPasswordMode |
how password is stored, clear text, or MD5 or SHA1 hashed. Default to TUserManagerPasswordMode::MD5. |
getRoles()
публичный метод
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.
getUser()
публичный метод
Returns a user instance given the user name.
public getUser ( $username = null ) : TUser |
Результат |
TUser |
the user instance, null if the specified username is not in the user database. |
getUserFile()
публичный метод
getUserFromCookie()
публичный метод
Returns a user instance according to auth data stored in a cookie.
public getUserFromCookie ( $cookie ) : TUser |
Результат |
TUser |
the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data. |
getUsers()
публичный метод
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()
публичный метод
Saves user auth data into a cookie.
setGuestName()
публичный метод
setPasswordMode()
публичный метод
setUserFile()
публичный метод
switchToGuest()
публичный метод
User name is changed as guest name, and roles are emptied.
validateUser()
публичный метод
Validates if the username and password are correct.