Show
Ignore:
Timestamp:
05/19/08 19:10:48 (19 months ago)
Author:
bchoate
Message:

Better handling for case where blog cookie and app session are out of sync. BugId:79508

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-38/lib/MT/App/Comments.pm

    r2377 r2393  
    114114    my $session_key; 
    115115 
    116     if (my $blog_id = $q->param('blog_id')) { 
    117         if (my $blog = MT::Blog->load($blog_id)) { 
    118             my $auths = $blog->commenter_authenticators || ''; 
    119             if ( $auths =~ /MovableType/ ) { 
    120                 # First, check for a real MT user login. If one exists, 
    121                 # return that as the commenter identity 
    122                 my ($user, $first_time) = $app->SUPER::login(); 
    123                 if ( $user ) { 
    124                     my $sess = $app->session; 
    125                     return ( $sess->id, $user ); 
    126                 } 
     116    my $blog = $app->blog; 
     117    if ($blog) { 
     118        my $auths = $blog->commenter_authenticators || ''; 
     119        if ( $auths =~ /MovableType/ ) { 
     120            # First, check for a real MT user login. If one exists, 
     121            # return that as the commenter identity 
     122            my ($user, $first_time) = $app->SUPER::login(); 
     123            if ( $user ) { 
     124                my $sess = $app->session; 
     125                return ( $sess->id, $user ); 
    127126            } 
    128127        } 
     
    149148      ) 
    150149    { 
    151         $app->log("session is invalid; sess_obj = $sess_obj; key = $session_key; user_id = $user_id; user = $user"); 
    152150        $app->_invalidate_commenter_session( \%cookies ); 
    153151        return ( undef, undef ); 
     
    858856        return $app->handle_error( 
    859857            $app->translate("Comment text is required.") ); 
     858    } 
     859 
     860    # validate session parameter 
     861    if ( my $sid = $q->param('sid') ) { 
     862        my ( $session, $commenter ) = $app->_get_commenter_session(); 
     863        if ( $session && $commenter && ( $session eq $sid ) ) { 
     864            # well, everything is okay 
     865        } else { 
     866            return $app->handle_error( 
     867                $app->translate("Your session has expired. Please sign in again to comment.") 
     868            ); 
     869        } 
    860870    } 
    861871 
     
    14461456    if ( $blog_id && $blog ) { 
    14471457        my ( $session, $commenter ) = $app->_get_commenter_session(); 
    1448 use Data::Dumper; 
    14491458        if ( $session && $commenter ) { 
    14501459            my $blog_perms = $commenter->blog_perm($blog_id); 
     
    14671476            my $can_post = ($blog_perms && $blog_perms->can_create_post) ? "1" : "0"; 
    14681477            $c = { 
     1478                sid => $sessobj->id, 
    14691479                name => $commenter->nickname, 
    14701480                url => $commenter->url,