Gossamer Forum
Home : Products : DBMan : Customization :

Generate userid and pass after add_success

Quote Reply
Generate userid and pass after add_success
HelloSmile

Modified a user friendly_html with Paasword lookup. My plan is;

After a add record success want to send a random userid (number) and pass (alpha) per email

to both admin and new guest. The new guest can now login with new pass

to the another add_form and alow to do that.

I am now stuck in, not find any modi form for this function.

Is anyone have experience in this or have seen that?

I looked up a lot other dicussions here but not found exact one yet.

Please write a massage if you by chance see this.

Thanks

Tilmes
Quote Reply
Re: [tilmes] Generate userid and pass after add_success In reply to
This has part of what you want... the email being sent to the user with a random password...

http://www.jpdeni.com/...s/secure_lookup.html

Do the Basic Mod from that page and if you want users to be able to change their pass/email add those additional mods from that page. I added the change pass mod from that page and it works well.

So far as emailing the admin, I'd look for the area in that mod that sends the email to the new user and add a few lines to also send the same info to the admin. Shouldn't be too difficult.

g'luck

Soil
Quote Reply
Re: [Soil] Generate userid and pass after add_success In reply to
Hello Soil,

thanks a lot for your reply.

I did modified this password lookup already. Sorry if i did not make clear in the context.

It generates new pass after new guest signs up.

What i want is generate both random userid (number) and pass (alpha) after he adds, in sub html_add_success. And can those id and pass save in .pass file?

So that he can later login to another .db with that?

I put the code under html_add_success and which allow to send email to both admin and new guest after success adds information.

It works, could you please think about how to generate those id and pass?

Thanks

Last edited by:

tilmes: Jan 13, 2002, 1:31 PM
Quote Reply
Re: [tilmes] Generate userid and pass after add_success In reply to
doh, after I replied I re-read your post and saw you already loaded the password lookup...

well in the basic mod JPDeni has a new sub-routine called "generate_password" (at the bottom) I guess you could copy that and then modify it for the random userid and add it to db.cgi. then go into the new signup sub-routine and modify that to also generate the new userid when someone attempts to signup.

btw, why do you want a random userID?

Soil
Quote Reply
Re: [Soil] Generate userid and pass after add_success In reply to
if you look inside that signup subroutine you can see the order...
Code:
# Add the userid into the file with default permissions.
open (PASSWD, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASSWD, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
print PASSWD "$userid:$encrypted:$view:$add:$del:$mod:$admin:$email\n";
close PASSWD;

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $in{'email'}\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $html_title New Password\n\n";

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

print MAIL "Here is your new $html_title password.\n\n";

print MAIL "Your $html_title User ID is: $userid\n";
print MAIL "Your $html_title password is: $password\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 "Please contact $html_title support at: $admin_email\n";
print MAIL "if you have any questions.\n\n";

close (MAIL);

&html_lookup_success;


It first saves the userid/pass/email/etc. to the password file then emails it out. So I'd put the call to the new userID just before it writes it to the password file.

Soil

Last edited by:

Soil: Jan 13, 2002, 1:31 PM
Quote Reply
Re: [Soil] Generate userid and pass after add_success In reply to
Hello Soil,

Modify with that code, creating pass to create new userid

I am not able to do that.Unsure maybe inserts numbers in the place abcdefgh..?

And new Userid must be also random which will be used as identifications number for the guest.

Maybe later after solve a random pass sent directly per email when adds success.

I did so far direct under sub html_add_success {

put; my (%rec) = &get_record($in{$db_key});

open (MAIL, "$mailprog")......

and now could able to receive a mail.

I do not understand what you mean. I'd put the call to the new userID just before it writes it to the password file.

How could let write random new userid and pass to password file and add informatins what new guest fills in the form in db file?

It is like brings password lookup functions into add_html.

Last edited by:

tilmes: Jan 13, 2002, 2:06 PM
Quote Reply
Re: [tilmes] Generate userid and pass after add_success In reply to
i think it writes it in this command:

Code:
print PASS "$in{'userid'}:$encrypted:$permissions:$in{'email'}\n";


so you might want to change $userid to $randomID in both that line and your new subroutine and that might work.

I'm not a true coder but I can hack others' code and get it to work and I think this should work. So here's my attempt at it:

1) create new subroutine and add it to the bottom of db.cgi:

Code:
sub generate_randomID {
my (@c, @v, $randomID); srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
@c = split(/ */, "bcdfghjklmnprstvwxyz");
@v = split(/ */, "aeiou");
for ($i=1; $i<=4; ++$i) {
$randomID .= $c[int(rand(20))] . $v[int(rand(5))];
}
return $randomID;
}


then add just below the line, in sub signup:

Code:
# Check to make sure userid is ok, pw ok, and userid is unique.


the line:

Code:
$in('userid') = $generate_randomID;


and try it. like I said, i'm not a true coder so there might be a few more things to add but this is where I'd start.

You might also want to tweak the srand numbers if the randomID ends up being similar to the password. It's basic on the time the sub is accessed so it should be different enough.

hope I'm not wasting your time.

Soil

Last edited by:

Soil: Jan 13, 2002, 2:16 PM
Quote Reply
Re: [Soil] Generate userid and pass after add_success In reply to
Hello soil, you gives a clue that pushs.

now i am succeeding with random pass, which writes in pass file and sent

random pass per email. But with random userid is not clear even though with studing

yours. I get per email $userid as same as password (alpha) ???



Below is changes in both db,html and db.cgi



sub html_add_success {

$password = &generate_password;
srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
my @salt_chars = ('A' .. 'Z', 0 .. 9, 'a' .. 'z', '.', '/');
my $salt = join '', @salt_chars[rand 64, rand 64];
my $encrypted = crypt($password, $salt);
open (PASSWD, ">>$auth_pw_file") or &cgierr ("unable to open: $auth_pw_file.\nReason: $!");
if ($db_use_flock) {
flock(PASSWD, 2) or &cgierr("unable to get exclusive lock on $auth_pw_file.\nReason: $!");
}
print PASSWD "$userid:$encrypted:$view:$add:$del:$mod:$admin:$email\n";
close PASSWD;

$userid = &generate_randomID;

print userid "$userid:$encrypted:$view:$add:$del:$mod:$admin:$email\n";
close userid;

my (%rec) = &get_record($in{$db_key});

open (MAIL, "$mailprog") || &cgierr("Can't start mail program");
print MAIL "To: $admin_email\n";
print MAIL "From: $admin_email\n";..........................

------------------------------------------------

db.cgi

sub generate_password {
# --------------------------------------------------------
#### Following subroutine added for secure_password_lookup mod

my (@c, @v, $password);

srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
@c = split(/ */, "bcdfghjklmnprstvwxyz");
@v = split(/ */, "aeiou");
for ($i=1; $i<=4; ++$i) {
$password .= $c[int(rand(20))] . $v[int(rand(5))];
}
return $password;
}

sub generate_randomID {
my (@c, @v, $randomID); srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
@c = split(/ */, "bcdfghjklmnprstvwxyz");
@v = split(/ */, "aeiou");
for ($i=1; $i<=4; ++$i) {
$randomID .= $c[int(rand(20))] . $v[int(rand(5))];
}
return $randomID;
}

thanks
------------------------------------------

now works with random userid which is sent to guest as a number but does not write in pass file?

after the change in db.cgi as belows;

sub generate_randomID {
my (@c, @v, $randomID); srand( time() ^ ($$ + ($$ << 15)) ); # Seed Random Number
@c = split(/ */, "1234567890");
@v = split(/ */, "5344");
for ($i=1; $i<=8; ++$i) {
$randomID .= $c[int(rand(20))] . $v[int(rand(5))];
}
return $randomID;
}

Last edited by:

tilmes: Jan 13, 2002, 3:09 PM
Quote Reply
Re: [tilmes] Generate userid and pass after add_success In reply to
cool, good job.

Soil
Quote Reply
Re: [Soil] Generate userid and pass after add_success In reply to
Hello soil, Thanks for your comliment.

I have some other changes though in this form.

and it does not write userid in pass file.Pirate
I have absolutly no clue about this matter.

Last edited by:

tilmes: Jan 13, 2002, 3:37 PM