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:
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:
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.
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.