Changeset 2403

Show
Ignore:
Timestamp:
05/20/08 20:16:24 (18 months ago)
Author:
bchoate
Message:

Updates to fix magic token parameter for edit profile. BugId:79822

Location:
branches/release-38
Files:
2 modified

Legend:

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

    r2393 r2403  
    103103# one already exists corresponding to the browser's session. 
    104104# 
    105 # Returns a pair ($session_key, $commenter) where $session_key is the 
    106 # key to the MT::Session object (as well as the cookie value) and 
    107 # $commenter is an MT::Author record. Both values are undef when no 
    108 # session is active. 
     105# Returns a pair ($session_obj, $commenter) where $session_obj is 
     106# a MT::Session object and $commenter is an MT::Author record. Both 
     107# values are undef when no session is active. 
    109108# 
    110109sub _get_commenter_session { 
     
    153152 
    154153    # session is valid! 
    155     return ( $session_key, $user ); 
     154    return ( $sess_obj, $user ); 
    156155} 
    157156 
     
    860859    # validate session parameter 
    861860    if ( my $sid = $q->param('sid') ) { 
    862         my ( $session, $commenter ) = $app->_get_commenter_session(); 
    863         if ( $session && $commenter && ( $session eq $sid ) ) { 
     861        my ( $sess_obj, $commenter ) = $app->_get_commenter_session(); 
     862        if ( $sess_obj && $commenter && ( $sess_obj->id eq $sid ) ) { 
    864863            # well, everything is okay 
    865864        } else { 
     
    12331232    my $nick  = $q->param('author'); 
    12341233    my $email = $q->param('email'); 
    1235     my ( $session, $commenter ); 
     1234    my ( $sess_obj, $commenter ); 
    12361235    if ( $blog->accepts_registered_comments ) { 
    1237         ( $session, $commenter ) = $app->_get_commenter_session(); 
     1236        ( $sess_obj, $commenter ) = $app->_get_commenter_session(); 
    12381237    } 
    12391238    if ( $commenter && ( 'do_reply' ne $app->mode ) ) { 
     
    14551454    my $c; 
    14561455    if ( $blog_id && $blog ) { 
    1457         my ( $session, $commenter ) = $app->_get_commenter_session(); 
    1458         if ( $session && $commenter ) { 
     1456        my ( $sessobj, $commenter ) = $app->_get_commenter_session(); 
     1457        if ( $sessobj && $commenter ) { 
    14591458            my $blog_perms = $commenter->blog_perm($blog_id); 
    14601459            my $banned = $commenter->is_banned($blog_id) ? "1" : "0"; 
     
    14621461            $banned ||= 1 if $commenter->status == MT::Author::BANNED(); 
    14631462 
    1464             my $sessobj = MT::Session->load( $session ); 
    14651463            if ($banned) { 
    14661464                $sessobj->remove; 
     
    17461744    my $app = shift; 
    17471745 
    1748     my ( $session, $commenter ) = $app->_get_commenter_session(); 
     1746    my ( $sess_obj, $commenter ) = $app->_get_commenter_session(); 
    17491747    if ($commenter) { 
    17501748        my $url; 
     
    17601758        } 
    17611759 
    1762         #require MT::Auth; 
    1763         #my $ctx = MT::Auth->fetch_credentials( { app => $app } ); 
    1764         #my $cmntr_sess = 
    1765         #  $app->session_user( $commenter, $ctx->{session_id}, 
    1766         #    permanent => $ctx->{permanent} ); 
    1767         #return $app->handle_error( $app->translate('Invalid login') ) 
    1768         #  unless $cmntr_sess; 
    1769  
    17701760        my $blog_id = $app->param('blog_id'); 
     1761        $app->{session} = $sess_obj; 
    17711762        $app->user($commenter); 
    17721763        my $param = { 
     
    17911782    my $q   = $app->param; 
    17921783 
     1784    my ( $sess_obj, $cmntr ) = $app->_get_commenter_session(); 
     1785    return $app->handle_error( $app->translate('Invalid login') ) 
     1786        unless $cmntr; 
     1787 
    17931788    my %param = 
    17941789      map { $_ => scalar( $q->param($_) ) } 
    1795       qw( id name nickname email password pass_verify hint url entry_url return_url external_auth); 
    1796  
    1797     unless ( $param{id} =~ /\d+/ ) { 
    1798         $param{error} = $app->translate('Invalid commenter ID'); 
    1799         return $app->build_page( 'profile.tmpl', \%param ); 
    1800     } 
    1801  
    1802     my $cmntr = MT::Author->load( $param{id} ); 
    1803     unless ($cmntr) { 
    1804         $param{error} = $app->translate('Invalid commenter ID'); 
    1805         return $app->build_page( 'profile.tmpl', \%param ); 
    1806     } 
     1790      qw( name nickname email password pass_verify hint url entry_url return_url external_auth); 
    18071791 
    18081792    $param{ 'auth_mode_' . $cmntr->auth_type } = 1; 
    18091793 
    1810     # require MT::Auth; 
    1811     # my $ctx = MT::Auth->fetch_credentials( { app => $app } ); 
    1812     # my $cmntr_sess = 
    1813     #  $app->session_user( $cmntr, $ctx->{session_id}, 
    1814     #    permanent => $ctx->{permanent} ); 
    1815     # return $app->handle_error( $app->translate('Invalid login') ) 
    1816     #  unless $cmntr_sess; 
    1817  
    18181794    $app->user($cmntr); 
     1795    $app->{session} = $sess_obj; 
     1796 
    18191797    $app->validate_magic 
    18201798      or return $app->handle_error( $app->translate('Invalid request') ); 
     
    18601838        $app->make_commenter_session( $cmntr ); 
    18611839    } 
     1840    $param{magic_token} = $app->current_magic; 
    18621841 
    18631842    return $app->build_page( 'profile.tmpl', \%param ); 
  • branches/release-38/tmpl/comment/profile.tmpl

    r2136 r2403  
    2222<input type="hidden" name="__mode" value="save_profile" /> 
    2323<input type="hidden" name="magic_token" value="<mt:var name="magic_token">" /> 
    24 <input type="hidden" name="id" value="<mt:var name="id" escape="html">" /> 
    2524<input type="hidden" name="entry_url" value="<mt:var name="entry_url" escape="html">" /> 
    2625<input type="hidden" name="return_url" value="<mt:var name="return_url" escape="html">" />