Changeset 2365 for branches/release-38/lib/MT/App/Comments.pm
- Timestamp:
- 05/16/08 19:51:05 (19 months ago)
- Files:
-
- 1 modified
-
branches/release-38/lib/MT/App/Comments.pm (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/release-38/lib/MT/App/Comments.pm
r2350 r2365 130 130 my $cfg = $app->config; 131 131 require MT::Session; 132 my $sess_obj = MT::Session->load( { id => $session_key } );132 my $sess_obj = MT::Session->load( { id => $session_key, kind => 'SI' } ); 133 133 my $timeout = $cfg->CommentSessionTimeout; 134 my $user; 135 136 if ( $sess_obj 137 && ( $user = MT::Author->load( { name => $sess_obj->name } ) ) ) 138 { 139 return ( $session_key, $user ) if $user->type eq MT::Author::AUTHOR(); 140 } 134 my $user_id = $sess_obj->get('author_id') if $sess_obj; 135 my $user = MT::Author->load( $user_id ) if $user_id; 136 141 137 if ( !$sess_obj 142 138 || ( $sess_obj->start() + $timeout < time ) 139 || ( !$user_id ) 140 || ( !$user ) 143 141 ) 144 142 { 143 $app->log("session is invalid; sess_obj = $sess_obj; key = $session_key; user_id = $user_id; user = $user"); 145 144 $app->_invalidate_commenter_session( \%cookies ); 146 145 return ( undef, undef ); 147 146 } 148 else { 149 # session is valid! 150 return ( $session_key, $user ); 151 } 147 148 # session is valid! 149 return ( $session_key, $user ); 152 150 } 153 151 … … 298 296 MT::Auth->new_login( $app, $commenter ); 299 297 if ( $app->_check_commenter_author( $commenter, $blog_id ) ) { 300 $app->make_commenter_session( $app->make_magic_token, 301 $commenter->email, $commenter->name, 302 ($commenter->nickname || $app->translate('(Display Name not set)')), 303 $commenter->id, undef, $ctx->{permanent} ? '+10y' : 0, $blog_id ); 298 $app->make_commenter_session( $commenter ); 304 299 return $app->redirect_to_target; 305 300 } … … 706 701 return 0; # Put a collar on that puppy. 707 702 } 703 704 return 1 unless $cfg->ShowIPInformation; 705 706 # If IP banning is enabled, check for lots of comments from 707 # the user's IP within the throttle period * 10; if they 708 # exceed 8 comments within that period, ban the IP. 709 708 710 @ts = MT::Util::offset_time_list( time - $throttle_period * 10 - 1, 709 711 $entry->blog_id ); … … 1108 1110 my $session_key = $cookies{$cookie_name}->value() || ""; 1109 1111 $session_key =~ y/+/ /; 1110 my $sessobj = MT::Session->load( $session_key);1112 my $sessobj = MT::Session->load({ id => $session_key, kind => 'SI' }); 1111 1113 return 1112 1114 if … … 1344 1346 ); 1345 1347 foreach (@old_sessions) { 1346 $_->remove() || die "couldn't remove sessions because " . $_->errstr();1348 $_->remove(); 1347 1349 } 1348 1350 } … … 1439 1441 if ( $blog_id && $blog ) { 1440 1442 my ( $session, $commenter ) = $app->_get_commenter_session(); 1443 use Data::Dumper; 1441 1444 if ( $session && $commenter ) { 1442 1445 my $blog_perms = $commenter->blog_perm($blog_id); … … 1445 1448 $banned ||= 1 if $commenter->status == MT::Author::BANNED(); 1446 1449 1447 my $sessobj = MT::Session->load( $session);1450 my $sessobj = MT::Session->load({ id => $session, kind => 'SI' }); 1448 1451 if ($banned) { 1449 1452 $sessobj->remove; 1450 1453 } else { 1451 1454 $sessobj->start( time + 1452 $app->config->CommentSessionTimeout); # extend by timeou 1455 $app->config->CommentSessionTimeout); # extend by timeout 1453 1456 $sessobj->save(); 1454 1457 } … … 1821 1824 } 1822 1825 if ($renew_session) { 1823 $app->make_commenter_session( $app->make_magic_token, $cmntr->email, 1824 $cmntr->name, 1825 ($cmntr->nickname || $app->translate('(Display Name not set)')), 1826 $cmntr->id ); 1826 $app->make_commenter_session( $cmntr ); 1827 1827 } 1828 1828
