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 TDbUserManager

TDbUserManager class

TDbUserManager manages user accounts that are stored in a database. TDbUserManager is mainly designed to be used together with TAuthManager which manages how users are authenticated and authorized in a Prado application.

To use TDbUserManager together with TAuthManager, configure them in the application configuration like following:

<module id="db"
    class="System.Data.TDataSourceConfig" ..../>
<module id="users"
    class="System.Security.TDbUserManager"
    UserClass="Path.To.MyUserClass"
    ConnectionID="db" />
<module id="auth"
    class="System.Security.TAuthManager"
    UserManager="users" LoginPage="Path.To.LoginPage" />

In the above, setUserClass UserClass specifies what class will be used to create user instance. The class must extend from TDbUser. setConnectionID ConnectionID refers to the ID of a TDataSourceConfig module which specifies how to establish database connection to retrieve user information.

TComponent
Extended by TApplicationComponent
Extended by TModule implements IModule
Extended by TDbUserManager implements IUserManager
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
# init( TXmlElement $config )

Initializes the module. This method is required by IModule and is invoked by application.

Initializes the module. This method is required by IModule and is invoked by application.

Parameters

$config
TXmlElement
module configuration

Overrides

TModule::init()
public string
# getUserClass( )

Returns

string
the user class name in namespace format. Defaults to empty string, meaning not set.
public
# setUserClass( string $value )

Parameters

$value
string
the user class name in namespace format. The user class must extend from TDbUser.
public string
# getGuestName( )

Returns

string
guest name, defaults to 'Guest'

Implementation of

IUserManager::getGuestName()
public
# setGuestName( string $value )

Parameters

$value
string
name to be used for guest users.
public boolean
# validateUser( string $username, string $password )

Validates if the username and password are correct.

Validates if the username and password are correct.

Parameters

$username
string
user name
$password
string
password

Returns

boolean
true if validation is successful, false otherwise.

Implementation of

IUserManager::validateUser()
public TUser
# getUser( string $username = null )

Returns a user instance given the user name.

Returns a user instance given the user name.

Parameters

$username
string
user name, null if it is a guest.

Returns

TUser
the user instance, null if the specified username is not in the user database.

Overrides

TApplicationComponent::getUser()

Implementation of

IUserManager::getUser()
public string
# getConnectionID( )

Returns

string
the ID of a TDataSourceConfig module. Defaults to empty string, meaning not set.
public
# setConnectionID( string $value )

Sets the ID of a TDataSourceConfig module. The datasource module will be used to establish the DB connection that will be used by the user manager.

Sets the ID of a TDataSourceConfig module. The datasource module will be used to establish the DB connection that will be used by the user manager.

Parameters

$value
string
module ID.
public TDbConnection
# getDbConnection( )

Returns

TDbConnection
the database connection that may be used to retrieve user data.
protected TDbConnection
# createDbConnection( string $connectionID )

Creates the DB connection.

Creates the DB connection.

Parameters

$connectionID
string
the module ID for TDataSourceConfig

Returns

TDbConnection
the created DB connection

Throws

TConfigurationException
if module ID is invalid or empty
public TDbUser
# getUserFromCookie( THttpCookie $cookie )

Returns a user instance according to auth data stored in a cookie.

Returns a user instance according to auth data stored in a cookie.

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

Implementation of

IUserManager::getUserFromCookie()
public
# saveUserToCookie( THttpCookie $cookie )

Saves user auth data into a cookie.

Saves user auth data into a cookie.

Parameters

$cookie
THttpCookie
the cookie to receive the user auth data.

Since

3.1.1

Implementation of

IUserManager::saveUserToCookie()
Methods inherited from TModule
getID(), setID()
Methods inherited from TApplicationComponent
getApplication(), getRequest(), getResponse(), getService(), getSession(), publishAsset(), publishFilePath()
Methods inherited from TComponent
__call(), __construct(), __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