Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

A revisit: Lost Password request by email

Quote Reply
A revisit: Lost Password request by email
I have read the threads on this subject that I could find ( primarily http://www.gossamer-threads.com/...orum.cgi?post=200949 and http://www.gossamer-threads.com/...orum.cgi?post=205223), but after finding no posts that seem to resolve this, I , too, will ask how I can modify the lost password request that will allow a user to retrieve the password by entering the email instead of the user name.

The original subroutine in GForum::User.pm:
Code:
$COMPILE{lost_password} = __LINE__ . <<'END_OF_SUB';
sub lost_password {
shift;
my ($do, $func) = @_;
my $page = $func->{page};
my $username = $IN->param('user_username');
my $user;
if ($username) {
my $User = $DB->table('User');
if ($user = $User->select({ user_username => $username })->fetchrow_hashref) {
my $temp_pass = random_password();
$User->update({ user_temp_pass => $temp_pass }, { user_id => $user->{user_id} });
if (my $error = send_temp_pass_email($user, $temp_pass)) {
die $error;
}
}
else {
return($page->{invalid_username} => { error => GForum::language('USER_INVALID_USERNAME', $username) });
}
}
else {
return($page->{enter_username});
}
return($page->{success}, $user);
}
END_OF_SUB


I changed references of "username" to "email", and "user_username" to "user_email", per the user table in the db.

I added a language var, naming it "USER_INVALID_USEREMAIL" with the text "%s is not a listed email address for a member of our forums."

I modified the template (lost_password_enter_username.html) in two places: changed "enter your user name" to "enter your email address" in the form, and replaced the "name" in "<input class="button" type="text" name="user_username">" with "<input class="button" type="text" name="user_email">"

To test it out, when I open the login page and then click on the link, /gforum.cgi?do=lost_password;), I get an internal server error; the error log states a premature end of script headers error in gforum.cgi.

Have I missed something? Is there something else I need to modify?

For your perusal, the subroutine as I modified it:
Code:
$COMPILE{lost_password} = __LINE__ . <<'END_OF_SUB';
sub lost_password {
shift;
my ($do, $func) = @_;
my $page = $func->{page};
my $useremail = $IN->param('user_email');
my $user;
if ($useremail) {
my $User = $DB->table('User');
if ($user = $User->select({ user_email => $useremail })->fetchrow_hashref) {
my $temp_pass = random_password();
$User->update({ user_temp_pass => $temp_pass }, { user_id => $user->{user_id} });
if (my $error = send_temp_pass_email($user, $temp_pass)) {
die $error;
}
}
else {
return($page->{invalid_email} => { error => GForum::language('USER_INVALID_USEREMAIL', $useremail) });
}
}
else {
return($page->{enter_email});
}
return($page->{success}, $user);
}
END_OF_SUB


Thanks in advance for any insight.
Winners never quit, and Quitters never win, and those who never ever win and never quit are called Idiots.
Subject Author Views Date
Thread A revisit: Lost Password request by email WhiteHat 8098 May 15, 2003, 3:40 PM
Thread Re: [WhiteHat] A revisit: I'll keep it short
WhiteHat 7921 May 16, 2003, 5:31 PM
Thread Re: [WhiteHat] A revisit: I'll keep it short
bretzke 7928 May 17, 2003, 5:44 AM
Thread Re: [bretzke] A revisit: I'll keep it short
hoefti 7852 May 23, 2003, 6:12 AM
Thread Re: [hoefti] A revisit: I'll keep it short
Paul 7864 May 23, 2003, 6:22 AM
Thread Re: [Paul] A revisit: I'll keep it short
hoefti 7852 May 23, 2003, 6:36 AM
Thread Retrieve password w/ e-mail address
ArmyAirForces 7858 May 25, 2003, 11:13 AM
Thread Re: [ArmyAirForces] Retrieve password w/ e-mail address
Jagerman 7836 May 25, 2003, 3:46 PM
Thread Re: [Jagerman] Retrieve password w/ e-mail address
ArmyAirForces 7817 May 25, 2003, 3:58 PM
Thread Re: [ArmyAirForces] Retrieve password w/ e-mail address
CRUZN8R 7824 May 25, 2003, 8:14 PM
Thread Re: [CRUZN8R] Retrieve password w/ e-mail address
ArmyAirForces 7790 May 25, 2003, 10:16 PM
Thread Re: [ArmyAirForces] Retrieve password w/ e-mail address
CRUZN8R 7839 May 25, 2003, 10:43 PM
Thread Re: [CRUZN8R] Retrieve password w/ e-mail address
ArmyAirForces 7807 May 26, 2003, 7:48 AM
Thread Re: [ArmyAirForces] Retrieve password w/ e-mail address
CRUZN8R 7803 May 26, 2003, 10:35 AM
Post Re: [CRUZN8R] Retrieve password w/ e-mail address
Jagerman 7800 May 26, 2003, 11:19 AM
Thread Re: [bretzke] A revisit: I'll keep it short
ellipsiiis 7770 May 26, 2003, 11:27 AM
Post Re: [ellipsiiis] A revisit: I'll keep it short
WhiteHat 7761 May 26, 2003, 8:14 PM