## Class TDbUserManager

Description

Implements interfaces:

- IUserManager

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
- version: $Id: TDbUserManager.php 2244 2007-09-26 13:15:56Z xue $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /Security/TDbUserManager.php (line 51)

    TComponent
       |
       --TApplicationComponent
          |
          --TModule
             |
             --TDbUserManager

Method Summary
TDbConnection createDbConnection (string $connectionID)
string getConnectionID ()
TDbConnection getDbConnection ()
string getGuestName ()
TUser getUser ([string $username = null])
string getUserClass ()
TDbUser getUserFromCookie (THttpCookie $cookie)
void init (TXmlElement $config)
void saveUserToCookie (THttpCookie $cookie)
void setConnectionID (string $value)
void setGuestName (string $value)
void setUserClass (string $value)
boolean validateUser (string $username, string $password)
Methods
createDbConnection (line 171)

Creates the DB connection.

- return: the created DB connection
- access: protected
- throws: TConfigurationException if module ID is invalid or empty

TDbConnection createDbConnection (string $connectionID)

- string $connectionID: the module ID for TDataSourceConfig

getConnectionID (line 136)

- return: the ID of a TDataSourceConfig module. Defaults to empty string, meaning not set.
- access: public

string getConnectionID ()
getDbConnection (line 155)

- return: the database connection that may be used to retrieve user data.
- access: public

TDbConnection getDbConnection ()
getGuestName (line 92)

- return: guest name, defaults to 'Guest'
- access: public

string getGuestName ()
getUser (line 121)

Returns a user instance given the user name.

- return: the user instance, null if the specified username is not in the user database.
- access: public

TUser getUser ([string $username = null])

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

Redefinition of:

TApplicationComponent::getUser()

getUserClass (line 76)

- return: the user class name in namespace format. Defaults to empty string, meaning not set.
- access: public

string getUserClass ()
getUserFromCookie (line 191)

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

- return: the user instance generated based on the cookie auth data, null if the cookie does not have valid auth data.
- access: public
- since: 3.1.1

TDbUser getUserFromCookie (THttpCookie $cookie)

- THttpCookie $cookie: the cookie storing user authentication information

init (line 64)

Initializes the module.

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

- access: public

void init (TXmlElement $config)

- TXmlElement $config: module configuration

Redefinition of:

TModule::init()
  Initializes the module.

saveUserToCookie (line 201)

Saves user auth data into a cookie.

- access: public
- since: 3.1.1

void saveUserToCookie (THttpCookie $cookie)

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

setConnectionID (line 147)

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.

- access: public

void setConnectionID (string $value)

- string $value: module ID.

setGuestName (line 100)

- access: public

void setGuestName (string $value)

- string $value: name to be used for guest users.

setUserClass (line 84)

- access: public

void setUserClass (string $value)

- string $value: the user class name in namespace format. The user class must extend from TDbUser.

validateUser (line 111)

Validates if the username and password are correct.

- return: true if validation is successful, false otherwise.
- access: public

boolean validateUser (string $username, string $password)

- string $username: user name
- string $password: password

#### Inherited Methods

Inherited From TModule

> TModule::getID()
> TModule::init()
> TModule::setID()

Inherited From TApplicationComponent

> TApplicationComponent::getApplication()
> TApplicationComponent::getRequest()
> TApplicationComponent::getResponse()
> TApplicationComponent::getService()
> TApplicationComponent::getSession()
> TApplicationComponent::getUser()
> TApplicationComponent::publishAsset()
> TApplicationComponent::publishFilePath()

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()

Documentation generated on Mon, 21 Apr 2008 11:34:55 -0400 by phpDocumentor 1.3.0RC4