| | 92 | |
| | 93 | <h2 id="5505">Using <tt>TDbUserManager</tt></h2> |
| | 94 | <p id="720563" class="block-content"> |
| | 95 | <tt>TDbUserManager</tt> is introduced in v3.1.0. Its main purpose is to simplify the task of managing user accounts that are stored in a database. It requires developers to write a user class that represents the necessary information for a user account. The user class must extend from <tt>TDbUser</tt>. |
| | 96 | </p> |
| | 97 | <p id="720564" class="block-content"> |
| | 98 | To use <tt>TDbUserManager</tt>, configure it in the application configuration like following: |
| | 99 | </p> |
| | 100 | <com:TTextHighlighter Language="xml" CssClass="source block-content" id="code4"> |
| | 101 | <module id="db" |
| | 102 | class="System.Data.TDataSourceConfig" ..../> |
| | 103 | <module id="users" |
| | 104 | class="System.Security.TDbUserManager" |
| | 105 | UserClass="Path.To.MyUserClass" |
| | 106 | ConnectionID="db" /> |
| | 107 | <module id="auth" |
| | 108 | class="System.Security.TAuthManager" |
| | 109 | UserManager="users" LoginPage="Path.To.LoginPage" /> |
| | 110 | </com:TTextHighlighter> |
| | 111 | |
| | 112 | </p> |
| | 113 | <p id="720565" class="block-content"> |
| | 114 | In the above, <tt>UserClass</tt> specifies what class will be used to create user instance. The class must extend from <tt>TDbUser</tt>. <tt>ConnectionID</tt> refers to the ID of a <tt>TDataSourceConfig</tt> module which specifies how to establish database connection to retrieve user information. |
| | 115 | </p> |
| | 116 | <p id="720566" class="block-content"> |
| | 117 | The user class has to implement the two abstract methods in <tt>TDbUser</tt>: <tt>validateUser()</tt> and <tt>createUser()</tt>. Since user account information is stored in a database, the user class may make use of its <tt>DbConnection</tt> property to reach the database. |
| | 118 | </p> |
| | 119 | |