Class Login

Description

The Login Module

This module can be used by other modules as follows:-

  • Copy module file to module directory
  • Adjust configuration file as needed (see further below on configuration file requirements)
  • In any action that requires the user to be logged in, run:
  • $this->exec_module_action('Login', 'check_login')
After login and logout, the module executes the default action specified in the configuration.

The Login module requires the following entries in the configuration file.

[login] mode = database or file : Authenticate against a 'database' or 'file' key_field = key_field_name : Name of the field that contains the primary key user_field = user_field_name : Name of the field that contains the user name pass_field = password_field_name : Name of the field that contains the password (encrypted using PASSWORD())

table = login_table_name : Name of the table in the database that contains login information

file = path/to/file : Location of the password file type = ini : Type of password file

The defaults are as below: [login] mode = database key_field = user_id user_field = email pass_field = password

table = user

file = "ini/password.ini" type = ini

This module requires the Config module when file based authentication is used.

Located in /modules/Login.php (line 41)

Module
   |
   --Login
Variable Summary
string $file
string $key_field
string $mode
string $pass_field
string $table
string $type
string $user_field
Method Summary
Login Login ()
void change_password ()
void check_login ([bool $forward = true])
mixed login_user ([string $module = 'Login'], [string $action = 'login_user'], [string $params = ''])
void login_user_form (string $module, string $action, [string $params = ''], [bool $failed = false])
void logout_user ([string $module = ''], [string $action = ''], [string $params = ''])
void update_login ( $new_login)
Variables
string $file = 'ini/password.ini' (line 82)
  • var:

    Location of the password file.

    Default: 'ini/password.ini'

string $key_field = 'user_id' (line 54)
  • var:

    Name of the field that contains the primary key

    Default: 'user_id'

string $mode = 'database' (line 47)
  • var:

    Authentication mode: 'database' or 'file'

    Default: 'database'

string $pass_field = 'password' (line 68)
  • var:

    Name of the field that contains the password (encrypted using PASSWORD())

    Default: 'password'

string $table = 'user' (line 75)
  • var:

    Name of the table in the database that contains login information

    Default: 'user'

string $type = 'ini' (line 89)
  • var:

    Type of password file: 'ini'

    Default: 'ini'

string $user_field = 'email' (line 61)
  • var:

    Name of the field that contains the user name

    Default: 'email'

Inherited Variables

Inherited from Module

Module::$application
Module::$controller
Module::$database
Module::$error
Module::$error_strings
Module::$exceptions
Module::$output
Module::$queries
Module::$sql
Module::$template_file
Module::$use_render
Module::$use_template_library
Module::$use_view
Methods
Constructor Login (line 96)

Constructor for Login module

Register exceptions in the constructor

Login Login ()
change_password (line 383)
void change_password ()
check_login (line 313)

Check if a user is logged in

void check_login ([bool $forward = true])
  • bool $forward: Forward the user to the login form if true (default: true)
get_configuration (line 114)

Get the configuration from the config file

void get_configuration ()
login_user (line 140)

Login the user

Use the following parameters if login processing is invoked from another module action.

  • return: If a module:action is specified, this action returns true (for login success) or the login form HTML (for login failure)
mixed login_user ([string $module = 'Login'], [string $action = 'login_user'], [string $params = ''])
  • string $module: Name of the module to process the login form (default: Login)
  • string $action: Name of the action to process the login form (default: login_user)
  • string $params: Parameters required for this module:action combination in "param=value&param=value" format. (default: '')
login_user_form (line 237)

Display login form

void login_user_form (string $module, string $action, [string $params = ''], [bool $failed = false])
  • string $module: Name of the module to process the login form
  • string $action: Name of the action to process the login form
  • string $params: Parameters required for this module:action combination in "param=value&param=value" format. (default: '')
  • bool $failed: Set to true if previous login attempt failed.
logout_user (line 209)

Log out the current user. This is done by deleting the session

The default or the specified module:action is executed after logging out.

void logout_user ([string $module = ''], [string $action = ''], [string $params = ''])
  • string $module: Name of the module to execute after logout
  • string $action: Name of the action to execute after logout
  • string $params: Parameters required for this module:action combination in "param=value&param=value" format. (default: '')
update_login (line 339)
void update_login ( $new_login)
  • $new_login

Inherited Methods

Inherited From Module

Module::disable_render()
Module::disable_template_library()
Module::disable_view()
Module::enable_render()
Module::enable_template_library()
Module::enable_view()
Module::exec_module_action()
Module::get_error_strings()
Module::get_exceptions()
Module::get_queries()
Module::get_templating_library_paths()
Module::initialize()
Module::PHPTAL_render()
Module::register_error()
Module::register_exception()
Module::register_query()
Module::render()
Module::set_references()
Module::set_template_file()
Module::Smarty_render()

Documentation generated on Sat, 23 Jun 2007 21:28:20 -0500 by phpDocumentor 1.3.2