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.
С версии: 3.0
Автор: Qiang Xue ([email protected])
Автор: Carl Mathisen ([email protected])
Наследование: extends Prado\TModule, implements IUserManager
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
getGuestName ( ) : string
getPasswordMode ( ) : TUserManagerPasswordMode
getRoles ( ) : array Returns an array of user role information.
getUser ( $username = null ) : TUser Returns a user instance given the user name.
getUserFile ( ) : string
getUserFromCookie ( $cookie ) : TUser Returns a user instance according to auth data stored in a cookie.
getUsers ( ) : array Returns an array of all users.
init ( $config ) Initializes the module.
saveUserToCookie ( $cookie ) Saves user auth data into a cookie.
setGuestName ( $value )
setPasswordMode ( $value )
setUserFile ( $value )
switchToGuest ( $user ) Sets a user as a guest.
validateUser ( $username, $password ) : boolean Validates if the username and password are correct.

Приватные методы

Метод Описание
loadUserData ( $config ) * Loads user/role information
loadUserDataFromPhp ( $config ) Loads user/role information from an php array.
loadUserDataFromXml ( $xmlNode ) Loads user/role information from an XML node.

Описание методов

getGuestName() публичный метод

public getGuestName ( ) : string
Результат string guest name, defaults to 'Guest'

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.
public getRoles ( ) : array
Результат array list of user role information

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() публичный метод

public getUserFile ( ) : string
Результат string the full path to the file storing user/role information

getUserFromCookie() публичный метод

Returns a user instance according to auth data stored in a cookie.
С версии: 3.1.1
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.
public getUsers ( ) : array
Результат array list of users

init() публичный метод

This method is required by IModule and is invoked by application. It loads user/role information from the module configuration.
public init ( $config )

saveUserToCookie() публичный метод

Saves user auth data into a cookie.
С версии: 3.1.1
public saveUserToCookie ( $cookie )

setGuestName() публичный метод

public setGuestName ( $value )

setPasswordMode() публичный метод

public setPasswordMode ( $value )

setUserFile() публичный метод

public setUserFile ( $value )

switchToGuest() публичный метод

User name is changed as guest name, and roles are emptied.
public switchToGuest ( $user )

validateUser() публичный метод

Validates if the username and password are correct.
public validateUser ( $username, $password ) : boolean
Результат boolean true if validation is successful, false otherwise.