Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TDbUserManager

TComponent
   |
   --TApplicationComponent
      |
      --TModule
         |
         --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:

  1. <module id="db"
  2. class="System.Data.TDataSourceConfig" ..../>
  3. <module id="users"
  4. class="System.Security.TDbUserManager"
  5. UserClass="Path.To.MyUserClass"
  6. ConnectionID="db" />
  7. <module id="auth"
  8. class="System.Security.TAuthManager"
  9. UserManager="users" LoginPage="Path.To.LoginPage" />

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

Since: 3.1.0
Author: Qiang Xue <qiang.xue@gmail.com>

Method Summary
protected  TDbConnection
createDbConnection ( string $connectionID)
Creates the DB connection.
string
TDbConnection
string
TUser
getUser ( string $username)
Returns a user instance given the user name.
string
TDbUser
Returns a user instance according to auth data stored in a cookie.
void
init ( TXmlElement $config)
Initializes the module.
void
Saves user auth data into a cookie.
void
setConnectionID ( string $value)
Sets the ID of a TDataSourceConfig module.
void
setGuestName ( string $value)
void
setUserClass ( string $value)
boolean
validateUser ( string $username, string $password)
Validates if the username and password are correct.
Methods Inherited From TModule
TModule::getID(), TModule::init(), TModule::setID()
Methods Inherited From TApplicationComponent
TApplicationComponent::getApplication(), TApplicationComponent::getRequest(), TApplicationComponent::getResponse(), TApplicationComponent::getService(), TApplicationComponent::getSession(), TApplicationComponent::getUser(), TApplicationComponent::publishAsset(), TApplicationComponent::publishFilePath()
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Method Details

createDbConnection

protected TDbConnection createDbConnection (string $connectionID )

Creates the DB connection.

Input
string$connectionIDthe module ID for TDataSourceConfig
Output
TDbConnection the created DB connection
Exception
throwsTConfigurationException if module ID is invalid or empty

getConnectionID

public string getConnectionID ()

Output
string the ID of a TDataSourceConfig module. Defaults to empty string, meaning not set.
Exception

getDbConnection

public TDbConnection getDbConnection ()

Output
TDbConnection the database connection that may be used to retrieve user data.
Exception

getGuestName

public string getGuestName ()

Output
string guest name, defaults to 'Guest'
Exception

getUser

public TUser getUser (string $username )

Returns a user instance given the user name.

Input
string$usernameuser name, null if it is a guest.
Output
TUser the user instance, null if the specified username is not in the user database.
Exception

getUserClass

public string getUserClass ()

Output
string the user class name in namespace format. Defaults to empty string, meaning not set.
Exception

getUserFromCookie

public TDbUser getUserFromCookie (THttpCookie $cookie )

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

Input
THttpCookie$cookiethe cookie storing user authentication information
Output
TDbUser the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
Exception

init

public void init (TXmlElement $config )

Initializes the module.

This method is required by IModule and is invoked by application.

Input
TXmlElement$configmodule configuration
Output
Exception

saveUserToCookie

public void saveUserToCookie (THttpCookie $cookie )

Saves user auth data into a cookie.

Input
THttpCookie$cookiethe cookie to receive the user auth data.
Output
Exception

setConnectionID

public void 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.

Input
string$valuemodule ID.
Output
Exception

setGuestName

public void setGuestName (string $value )

Input
string$valuename to be used for guest users.
Output
Exception

setUserClass

public void setUserClass (string $value )

Input
string$valuethe user class name in namespace format. The user class must extend from TDbUser.
Output
Exception

validateUser

public boolean validateUser (string $username , string $password )

Validates if the username and password are correct.

Input
string$usernameuser name
string$passwordpassword
Output
boolean true if validation is successful, false otherwise.
Exception