]> mj.ucw.cz Git - pciids.git/blobdiff - PciIds/Users.pm
New item -> notification
[pciids.git] / PciIds / Users.pm
index eb49ba3e21547f0404689d6651040614f59604ba..d6b136714613d2aff7a6008d6610c0515b52eec7 100644 (file)
@@ -18,7 +18,7 @@ our @EXPORT = qw(&addUser &emailConfirm &checkConfirmHash &saltedPasswd &genAuth
 sub emailCheck( $$ ) {
        my( $email, $tables ) = @_;
        my $newmail;
-       return 'Does not look like an email address' unless ( ( $newmail ) = ( $email =~ /^([^,? "'`;]+@[^@,?\/ "'`;]+)$/ ) );#make sure the mail is not only reasonable looking, but safe to work with too
+       return 'Does not look like an email address' unless ( ( $newmail ) = ( $email =~ /^([^,? "'`;<>]+@[^@,?\/ "'`;<>]+)$/ ) );#make sure the mail is not only reasonable looking, but safe to work with too
        return 'Email too long' if length $newmail > 255;
        return 'An account for this email address already exists' if( ( defined $tables ) && $tables->hasEmail( $newmail ) );
        return ( undef, $newmail );
@@ -64,8 +64,8 @@ sub changePasswd( $$$$ ) {
        $tables->changePasswd( $id, $salted );
 }
 
-sub genAuthToken( $$$$ ) {
-       my( $tables, $id, $req, $rights ) = @_;
+sub genAuthToken( $$$$$ ) {
+       my( $tables, $id, $req, $rights, $name ) = @_;
        unless( defined $rights ) {#Just logged in
                my $from = $req->connection()->remote_ip();
                $tables->setLastLog( $id, $from );
@@ -74,13 +74,13 @@ sub genAuthToken( $$$$ ) {
        my $haveRights = scalar @{$rights};
        my $time = time;
        my $ip = $req->connection()->remote_ip();
-       return "$id:$haveRights:$time:".md5_hex( "$id:$time:$ip:".$config{'authsalt'} );
+       return "$id:$haveRights:$time:".md5_hex( "$id:$time:$ip:".$config{'authsalt'} ).":$name";
 }
 
 sub checkAuthToken( $$$ ) {
        my( $tables, $req, $token ) = @_;
-       my( $id, $haveRights, $time, $hex ) = defined( $token ) ? split( /:/, $token ) : ();
-       return ( 0, 0, 0, [], "Not logged in" ) unless( defined $hex );
+       my( $id, $haveRights, $time, $hex, $name ) = defined( $token ) ? split( /:/, $token ) : ();
+       return ( 0, 0, 0, [], "Not logged in", undef ) unless( defined $hex );
        my $ip = $req->connection()->remote_ip();
        my $expected = md5_hex( "$id:$time:$ip:".$config{'authsalt'} );
        my $actTime = time;
@@ -96,7 +96,7 @@ sub checkAuthToken( $$$ ) {
                        push @{$rights}, \%r;
                }
        }
-       return ( $authed, $id, $regen, $rights, $authed ? undef : ( $tokOk ? "Login timed out" : "Not logged in x" ) );
+       return ( $authed, $id, $regen, $rights, $authed ? undef : ( $tokOk ? "Login timed out" : "Not logged in" ), $name );
 }
 
 sub hasRight( $$ ) {