Update of /cvs/scoop/scoop/lib/Scoop/Users
In directory lithium.sabren.com:/tmp/cvs-serv16309/lib/Scoop/Users
Modified Files:
NewUser.pm Prefs.pm
Log Message:
Omnibus AZ patch:
* Adds new signup method where user chooses their own password. This has worked a lot better than the old way for us, and is much easier
for inexperienced users. For people upgrading, you'll need to edit a bunch of user-related blocks, most notably changing new_user_email
and adding a box call to new_user_html. Some instructions are with the control var "signup_with_password"
* Adds flexible date formatting with the vars date_format_default, date_format_short, and date_format_wmd
* Adds user signup IP tracking. Very handy for tracking down dupe accounts and persistent trolls.
Index: NewUser.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Users/NewUser.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** NewUser.pm 23 Jan 2005 03:45:59 -0000 1.4
--- NewUser.pm 25 Jan 2005 17:15:24 -0000 1.5
***************
*** 94,98 ****
if ($tool eq 'writeuser') {
$uname = $S->{CGI}->param('nickname');
!
if( $really_new_user ) {
if ($error .= $S->filter_new_username($uname)) {
--- 94,99 ----
if ($tool eq 'writeuser') {
$uname = $S->{CGI}->param('nickname');
! my $pass2;
!
if( $really_new_user ) {
if ($error .= $S->filter_new_username($uname)) {
***************
*** 107,110 ****
--- 108,118 ----
$email = '';
}
+
+ if ($S->{UI}->{VARS}->{signup_with_password}) {
+ my $p_error .= $S->check_newuser_pass();
+ $pass2 = $S->cgi->param('pass1') unless ($p_error);
+ $error .= $p_error;
+ }
+
}
***************
*** 122,126 ****
my $rv;
if ($really_new_user) {
! $rv = $S->create_user_step_1($uname, $pass1, $email);
} elsif ($is_advertiser) {
$rv = $S->store_advertiser_info($S->{UID});
--- 130,134 ----
my $rv;
if ($really_new_user) {
! $rv = $S->create_user_step_1($uname, $pass1, $email, $pass2);
} elsif ($is_advertiser) {
$rv = $S->store_advertiser_info($S->{UID});
***************
*** 226,243 ****
sub create_user_step_1 {
! my $S = shift;
! my ($nick, $pass, $email) = @_;
! my $c_pass = $S->dbh->quote($S->crypt_pass($pass));
! my $f_nick = $S->dbh->quote($nick);
! my $f_email = $S->dbh->quote($email);
! my $default_group = $S->dbh->quote($S->_get_default_group);
my $ip = $S->dbh->quote($S->{REMOTE_IP});
! my ($rv, $sth) = $S->db_insert({
INTO => 'users',
COLS => 'nickname, origemail, realemail, passwd, perm_group, creation_ip, creation_time, is_new_account',
! VALUES => qq|$f_nick, $f_email, $f_email, $c_pass, $default_group, $ip, NOW(),1|});
$sth->finish;
--- 234,264 ----
sub create_user_step_1 {
! my $S = shift;
! my ($nick, $pass, $email, $real_pass) = @_;
! my $pass_to_crypt = ($S->{UI}->{VARS}->{signup_with_password}) ? $real_pass : $pass;
! my $c_pass = $S->dbh->quote($S->crypt_pass($pass_to_crypt));
! my $f_nick = $S->dbh->quote($nick);
! my $f_email = $S->dbh->quote($email);
!
! my $default_group = $S->dbh->quote($S->_get_default_group);
my $ip = $S->dbh->quote($S->{REMOTE_IP});
!
! my $insert = {
INTO => 'users',
COLS => 'nickname, origemail, realemail, passwd, perm_group, creation_ip, creation_time, is_new_account',
! VALUES => qq|$f_nick, $f_email, $f_email, $c_pass, $default_group, $ip, NOW(),1|
! };
!
! if ($S->{UI}->{VARS}->{signup_with_password}) {
! my $q_pass = $S->dbh->quote($real_pass);
! my $i_pass = $S->dbh->quote($pass);
! $insert->{COLS} = 'nickname, origemail, realemail, passwd, newpasswd, creation_passwd, perm_group, creation_ip, creation_time, is_new_account';
! $insert->{VALUES} = qq|$f_nick, $f_email, $f_email, $i_pass, $c_pass, $q_pass, $default_group, $ip, NOW(),1|;
! }
!
! my ($rv, $sth) = $S->db_insert($insert);
$sth->finish;
***************
*** 272,283 ****
my $content = $S->{UI}->{BLOCKS}->{new_user_email};
! $content =~ s/%%nick%%/$nick/;
! $content =~ s/%%pass%%/$pass/;
! $content =~ s/%%url%%/$path/;
! $content =~ s/%%showprefs%%/$showprefs/;
! $content =~ s/%%from%%/$from/;
! $content =~ s/%%sitename%%/$sitename/;
! $subject =~ s/%%sitename%%/$sitename/;
$rv = $S->mail($email, $subject, $content, $from);
--- 293,304 ----
my $content = $S->{UI}->{BLOCKS}->{new_user_email};
! $content =~ s/%%nick%%/$nick/g;
! $content =~ s/%%pass%%/$pass/g;
! $content =~ s/%%url%%/$path/g;
! $content =~ s/%%showprefs%%/$showprefs/g;
! $content =~ s/%%from%%/$from/g;
! $content =~ s/%%sitename%%/$sitename/g;
! $subject =~ s/%%sitename%%/$sitename/g;
$rv = $S->mail($email, $subject, $content, $from);
***************
*** 391,393 ****
--- 412,427 ----
+ sub check_newuser_pass {
+ my $S = shift;
+ my $pass1 = $S->cgi->param('pass1');
+ my $pass2 = $S->cgi->param('pass2');
+
+ # Do they match?
+ return qq|<br> The two password fields do not match. Please enter your password again.|
+ unless ($pass1 eq $pass2);
+
+ # Ok.
+ return '';
+ }
+
1;
Index: Prefs.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Users/Prefs.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Prefs.pm 27 Aug 2004 22:32:52 -0000 1.3
--- Prefs.pm 25 Jan 2005 17:15:24 -0000 1.4
***************
*** 135,139 ****
'perm_group' => $user->{perm_group},
'mojo' => $user->{mojo},
! 'creation_ip' => $user->{creation_ip},
'creation_time' => $user->{creation_time} };
--- 135,139 ----
'perm_group' => $user->{perm_group},
'mojo' => $user->{mojo},
! 'creation_ip' => qq|<a href="/iplookup/$user->{creation_ip}">$user->{creation_ip}</a>|,
'creation_time' => $user->{creation_time} };
***************
*** 154,158 ****
$preftemplate = $S->interpolate($preftemplate,$preflist);
$return =~ s/%%itemlist%%/$adminpreftemplate\n$preftemplate/;
! $return =~ s/%%userpref_reset%%//;
} else {
# Now for all the dynamically generated pages
--- 154,158 ----
$preftemplate = $S->interpolate($preftemplate,$preflist);
$return =~ s/%%itemlist%%/$adminpreftemplate\n$preftemplate/;
! $return =~ s/%%userpref_reset%%//g;
} else {
# Now for all the dynamically generated pages