Gossamer Forum
Home : Products : DBMan SQL : Development, Plugins and Globals :

log in with email address

Quote Reply
log in with email address
ok, i think i have it working now but am a little afraid something may be messed up because dumper shows two Tablename variables - one is blank, the other is the current table.

1. i added email field to the login form (html)

2. in sub _authenticate (home.pm) i tested for existence of the $email variable and used it to lookup the user in the user table.
# Authenticate the user.
my $username = $self->{cgi}->{Username};
my $password = $self->{cgi}->{Password};
my $email = $self->{cgi}->{Email}; # 8/06/2010

# 8/10/2010
if ($email) {
my $cond = new GT::SQL::Condition;
my $user_table = $self->{glb_cfg}->{default_user_table};
$cond->add(Email => '=' => $email);
my $sth = $self->{sql}->table($user_table)->select($cond, ['Username']);

my $rs = $sth->fetchrow_hashref;
$username = $rs->{Username};
$self->{cgi}->{Username} = $rs->{Username};

3. once i had the username associated with the email address, i made no other changes but let the script do the regular authentication with the username and password.

do you see any problems here?