NAME

Egg::Plugin::SessionKit::Auth::DBI - Data is acquired and authentication from the data base.

SYNOPSIS

package MYPROJECT;
use strict;
use Egg qw/Plugin::SessionKit::Auth::DBI/;

Configuration.

plugin_session=> {
  ...
  ...
  auth=> {
    ...
    ...
    dbname         => 'member_data',
    uid_db_field   => 'user_id',
    psw_db_field   => 'password',
    active_db_field=> 'active',
    restore_sql    => 'SELECT * FROM <# dbname #> a JOIN profile b'
                   . ' ON a.<# uid_db_field #> = b.<# uid_db_field #>'
                   . ' WHERE a.<# uid_db_field #> = ? ',
  },
},

Example of code.

my $auth= $e->auth;  # Auth object is acquired.

if ($auth->user_name) {
	print "Login is done.";

	my $email= $auth->user->{email} || "";

} else {
	print "It doesn't login.";
}

DESCRIPTION

Data is acquired and attested by SQL set to 'restore_sql'.

<# configuration name #> in 'restore_sql' can be substituted by other set values.

The data acquired here can be referred to through $e->auth->user when login succeeds.

CONFIGURATION

dbname

Table name of authentication data.

Default is 'members'

uid_db_field

Name of id field

Default is none., Undefined is an error.

psw_db_field

Default is none., Undefined is an error.

active_db_field

Field name to judge whether acquired data is effective. This is evaluated only when defined.

For instance, if this field is undefined even if succeeding in the acquisition of data because of the inquiry of $e->auth->login, false is returned.

Default is none.

restore_sql

SQL sentence to acquire attestation data.

Substitution that uses <# configuration name #> can be done.

I think a little complex SELECT sentence to be treatable mostly well. However, it should be SQL sentence that at least acquires ID and password.

Default is 'SELECT * FROM <# dbname #> WHERE <# uid_db_field #> = ?'

METHODS

$e->auth->login

The login check is done.

Please see Egg::Plugin::SessionKit::Auth in detail.

$e->auth->restore([USER_ID]);

The attestation data corresponding to specified ID is returned by the HASH reference.

BUGS

When wrong 'restore_sql' was set, it suffered from the freezed symptom. The current cause of the place cannot specify this error.

SEE ALSO

Egg::SessionKit, Egg::SessionKit::Auth, Egg::Release,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT

Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.