PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class TDbUser

TDbUser class

TDbUser is the base user class for using together with TDbUserManager. Two methods are declared and must be implemented in the descendant classes:

  • TDbUser::validateUser(): validates if username and password are correct entries.
  • TDbUser::createUser(): creates a new user instance given the username
TComponent
Extended by TUser implements IUser
Extended by TDbUser
Abstract
Package: System\Security
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.1.0
Located at Security/TDbUserManager.php
Methods summary
public TDbConnection
# getDbConnection( )

Returns a database connection that may be used to retrieve data from database.

Returns a database connection that may be used to retrieve data from database.

Returns

TDbConnection
database connection that may be used to retrieve data from database
abstract public boolean
# validateUser( string $username, string $password )

Validates if username and password are correct entries. Usually, this is accomplished by checking if the user database contains this (username, password) pair. You may use getDbConnection DbConnection to deal with database.

Validates if username and password are correct entries. Usually, this is accomplished by checking if the user database contains this (username, password) pair. You may use getDbConnection DbConnection to deal with database.

Parameters

$username
string
username (case-sensitive)
$password
string
password

Returns

boolean
whether the validation succeeds
abstract public TDbUser
# createUser( string $username )

Creates a new user instance given the username. 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.

Creates a new user instance given the username. 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 getDbConnection DbConnection to deal with database.

Parameters

$username
string
username (case-sensitive)

Returns

TDbUser
the newly created and initialized user instance
public TDbUser
# createUserFromCookie( THttpCookie $cookie )

Creates a new user instance given the cookie containing auth data.

Creates a new user instance given the cookie containing auth data.

This method is invoked when 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.

Parameters

$cookie
THttpCookie
the cookie storing user authentication information

Returns

TDbUser
the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.

Since

3.1.1

See

TDbUser::saveUserToCookie()
public
# saveUserToCookie( THttpCookie $cookie )

Saves necessary auth data into a cookie. This method is invoked when 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.)

Saves necessary auth data into a cookie. This method is invoked when 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.

Parameters

$cookie
THttpCookie
the cookie to store the user auth information

Since

3.1.1

See

TDbUser::createUserFromCookie()
Methods inherited from TUser
__construct(), getIsGuest(), getManager(), getName(), getRoles(), getState(), getStateChanged(), isInRole(), loadFromString(), saveToString(), setIsGuest(), setName(), setRoles(), setState(), setStateChanged()
Methods inherited from TComponent
__call(), __destruct(), __get(), __isset(), __set(), __sleep(), __unset(), __wakeup(), addParsedObject(), asa(), attachBehavior(), attachBehaviors(), attachClassBehavior(), attachEventHandler(), canGetProperty(), canSetProperty(), clearBehaviors(), createdOnTemplate(), detachBehavior(), detachBehaviors(), detachClassBehavior(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), evaluateStatements(), fxAttachClassBehavior(), fxDetachClassBehavior(), getAutoGlobalListen(), getBehaviorsEnabled(), getClassHierarchy(), getEventHandlers(), getListeningToGlobalEvents(), getSubProperty(), hasEvent(), hasEventHandler(), hasProperty(), isa(), listen(), raiseEvent(), setSubProperty(), unlisten()
Constants inherited from TComponent
GLOBAL_RAISE_EVENT_LISTENER
Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO