]> mj.ucw.cz Git - pciids.git/blobdiff - PciIds/Users.pm
update-web: Synchronize mirrors
[pciids.git] / PciIds / Users.pm
index a1087c16b084a92eab4e9681d117b0bbf235a423..bf6ced2b2becf4ba9753c4f8991f1013774887be 100644 (file)
@@ -1,3 +1,21 @@
+#      PciIds web database
+#      Copyright (C) 2008 Michal Vaner (vorner@ucw.cz)
+#
+#      This program is free software; you can redistribute it and/or modify
+#      it under the terms of the GNU General Public License as published by
+#      he Free Software Foundation; either version 2 of the License, or
+#      (at your option) any later version.
+#
+#      This program is distributed in the hope that it will be useful,
+#      but WITHOUT ANY WARRANTY; without even the implied warranty of
+#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#
+#      GNU General Public License for more details.
+#
+#      You should have received a copy of the GNU General Public License
+#      along with this program; if not, write to the Free Software
+#      Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
 package PciIds::Users;
 use strict;
 use warnings;
@@ -67,22 +85,20 @@ sub changePasswd( $$$$ ) {
 sub genAuthToken( $$$$$ ) {
        my( $tables, $id, $req, $rights, $name ) = @_;
        unless( defined $rights ) {#Just logged in
-               my $from = $req->connection()->remote_ip();
+               my $from = $req->useragent_ip();
                $tables->setLastLog( $id, $from );
                $rights = $tables->rights( $id );
        }
        my $haveRights = scalar @{$rights};
        my $time = time;
-       my $ip = $req->connection()->remote_ip();
-       return "$id:$haveRights:$time:".md5_hex( "$id:$time:$ip:".$config{'authsalt'} ).":$name";
+       return "$id:$haveRights:$time:".md5_hex( "$id:$time:".$config{'authsalt'} ).":$name";
 }
 
 sub checkAuthToken( $$$ ) {
        my( $tables, $req, $token ) = @_;
        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 $expected = md5_hex( "$id:$time:".$config{'authsalt'} );
        my $actTime = time;
        my $tokOk = ( $expected eq $hex );
        my $authed = ( $tokOk && ( $time + $config{'authtime'} > $actTime ) );
@@ -127,7 +143,7 @@ sub pushProfile( $$$$ ) {
 checkConf( [ 'passwdsalt', 'regmailsalt', 'authsalt' ] );
 defConf( { 'authtime' => 2100, 'regenauthtime' => 300 } );
 
-open PRIVS, $directory."/rights" or die "Could not open privilege definitions\n";
+open PRIVS, $directory."cf/rights" or die "Could not open privilege definitions\n";
 foreach( <PRIVS> ) {
        my( $num, $name ) = /^(\d+)\s+(.*)$/ or die "Invalid syntax in privileges\n";
        $privnames{$num} = $name;