- Home
- About
- Testimonials
- Demos
- Download
- Documentation
- Blogs
- Forum
- Support

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:
IUserManager
TAuthManager
TAuthorizationRule
TAuthorizationRuleCollection
TDbUser
TDbUserManager
TSecurityManager
TSecurityManagerValidationMode
TUser
TUserManager
TUserManagerPasswordMode

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:

     <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, 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 | getConnectionID ()
TDbConnection | getDbConnection ()
string | getGuestName ()
TUser | getUser ( string $username) Returns a user instance given the user name.
string | getUserClass ()
TDbUser | getUserFromCookie ( THttpCookie $cookie) Returns a user instance according to auth data stored in a cookie.
void | init ( TXmlElement $config) Initializes the module.
void | saveUserToCookie ( THttpCookie $cookie) 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 | $connectionID | the module ID for TDataSourceConfig
Output
TDbConnection | the created DB connection
Exception
throws | TConfigurationException 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 | $username | user 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 | $cookie | the 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 | $config | module configuration
Output
Exception

## saveUserToCookie

public void saveUserToCookie | (THttpCookie $cookie )

Saves user auth data into a cookie.

Input
THttpCookie | $cookie | the 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 | $value | module ID.
Output
Exception

## setGuestName

public void setGuestName | (string $value )

Input
string | $value | name to be used for guest users.
Output
Exception

## setUserClass

public void setUserClass | (string $value )

Input
string | $value | the 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 | $username | user name
string | $password | password
Output
boolean | true if validation is successful, false otherwise.
Exception