PHP 클래스 Prado\Security\TDbUser

TDbUser is the base user class for using together with {@link TDbUserManager}. Two methods are declared and must be implemented in the descendant classes: - {@link validateUser()}: validates if username and password are correct entries. - {@link createUser()}: creates a new user instance given the username
부터: 3.1.0
저자: Qiang Xue ([email protected])
상속: extends TUser
파일 보기 프로젝트 열기: pradosoft/prado

공개 메소드들

메소드 설명
createUser ( $username ) : TDbUser Creates a new user instance given the username.
createUserFromCookie ( $cookie ) : TDbUser Creates a new user instance given the cookie containing auth data.
getDbConnection ( ) : TDbConnection Returns a database connection that may be used to retrieve data from database.
saveUserToCookie ( $cookie ) Saves necessary auth data into a cookie.
validateUser ( $username, $password ) : boolean Validates if username and password are correct entries.

메소드 상세

createUser() 추상적인 공개 메소드

This method usually needs to retrieve necessary user information (e.g. role, name, rank, etc.) from the user database according to the specified username. The newly created user instance should be initialized with these information. If the username is invalid (not found in the user database), null should be returned. You may use {@link getDbConnection DbConnection} to deal with database.
abstract public createUser ( $username ) : TDbUser
리턴 TDbUser the newly created and initialized user instance

createUserFromCookie() 공개 메소드

This method is invoked when {@link TAuthManager::setAllowAutoLogin AllowAutoLogin} is set true. The default implementation simply returns null, meaning no user instance can be created from the given cookie. If you want to support automatic login (remember login), you should override this method. Typically, you obtain the username and a unique token from the cookie's value. You then verify the token is valid and use the username to create a user instance.
또한 보기: saveUserToCookie
부터: 3.1.1
public createUserFromCookie ( $cookie ) : TDbUser
리턴 TDbUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.

getDbConnection() 공개 메소드

Returns a database connection that may be used to retrieve data from database.
public getDbConnection ( ) : TDbConnection
리턴 Prado\Data\TDbConnection database connection that may be used to retrieve data from database

saveUserToCookie() 공개 메소드

This method is invoked when {@link TAuthManager::setAllowAutoLogin AllowAutoLogin} is set true. The default implementation does nothing, meaning auth data is not stored in the cookie (and thus automatic login is not supported.) If you want to support automatic login (remember login), you should override this method. Typically, you generate a unique token according to the current login information and save it together with the username in the cookie's value. You should avoid revealing the password in the generated token.
또한 보기: createUserFromCookie
부터: 3.1.1
public saveUserToCookie ( $cookie )

validateUser() 추상적인 공개 메소드

Usually, this is accomplished by checking if the user database contains this (username, password) pair. You may use {@link getDbConnection DbConnection} to deal with database.
abstract public validateUser ( $username, $password ) : boolean
리턴 boolean whether the validation succeeds