Gossamer Forum
Home : Products : DBMan : Customization :

Ask for random pwd for new account

Quote Reply
Ask for random pwd for new account
Hello all,

I use the JPDeni friendly html.pl and change pwd.
Now gen the random pwd for 1st login, let new user input account name and email only.
The random pwd will send email to their.

Thx


------------------
Quote Reply
Re: Ask for random pwd for new account In reply to
Delete the password field in html_signup_form. Change the wording on the form to tell users their passwords will be sent to the email address they enter.

Replace sub signup in db.cgi with the following:

Code:
sub signup {
# --------------------------------------------------------
# Allows a user to sign up without admin approval. Must have $auth_signup = 1
# set. The user gets @signup_permissions.
#
my ($userid, $email, $message);

# Check to make sure userid is ok, pw ok, and userid is unique.
unless ((length($in{'userid'}) >= 3) and (length($in{'userid'}) <= 12) and ($in{'userid'} =~ /^[a-zA-Z0-9]+$/)) {
$message = "Invalid userid: $in{'userid'}. Must only contain only letters
and be less then 12 and greater then 3 characters.<BR>";
}
unless (($in{'email'}) and ($in{'email'} =~ /.+\@.+\..+/)) {
$message .= "Invalid email address: '$in{'email'}'.<BR>";
}
open (PASSWD, "<$auth_pw_file") or &cgierr("unable to open password file. Reason: $!\n");
@passwds = <PASSWD>;
close PASSWD;
PASS: foreach $pass (@passwds) {
next PASS if ($pass =~ /^$/);
next PASS if ($pass =~ /^#/);
chomp ($pass);
($userid, $pw, $view, $add, $del, $mod, $admin,$email) = split (/:/, $pass);
if ($in{'userid'} eq $userid) {
$message = "User name already in use. Try another<BR>";
}
if ($in{'email'} eq $email) {
$message .= "Email address already in password file.";
}
}
if ($message) {
&html_signup_form ($message);
return;
}
# Create password

@c = split(/ */, "bcdfghjklmnprstvwxyz");
@v = split(/ */, "aeiou");
for ($i = 1 ; $i <= 4; $i +=1 ) {
$in{'pw'} = $in{'pw'} . $c[int(rand(20))]. $v[int(rand(5))];
}
# Add the userid into the file
open (PASS, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASS, 2) or &cgierr("unable to get exclusive lock on
$auth_pw_file.\nReason: $!");
}
my $permissions = join (":", @auth_signup_permissions);
print PASS "$in{'userid'}:$in{'pw'}:$permissions:$in{'email'}\n";
close PASS;

open (MAIL, "$mailprog") or &cgierr("Can't start mail program");

print MAIL "To: $in{'email'}\n";
print MAIL "From: $admin_email\n";
print MAIL "Reply-to: $admin_email\n";
print MAIL "Subject: $db_name Account Created\n\n";

print MAIL "-" x 75 . "\n\n";

print MAIL "Your account at $db_name has been created.\n\n";

print MAIL "Your $db_name User ID is: $in{'userid'}\n";
print MAIL "Your $db_name password is: $in{'pw'}\n\n";

print MAIL "Please keep this email for future reference.\n\n";

print MAIL "To log on, go to\n\n";
print MAIL "$db_script_url?db=$db_setup\n";
print MAIL "and enter your User ID and password.\n\n";

print MAIL "After you log on, you may change your password to one of your\n";
print MAIL qq|own choosing by selecting the "Change Password" link in the\n|;
print MAIL "menu at the bottom of each page.\n\n";

print MAIL "Please contact $db_name support at: $admin_email\n";
print MAIL "if you have any questions.\n\n";

close (MAIL);
&html_signup_success;
}

------------------
JPD





Quote Reply
Re: Ask for random pwd for new account In reply to
Thx