Make OpenID logins from the navstrip also follow the same path as a 
regular login. So v
        alidated OpenID accounts will be redirected to the page they came from; 
non-validated o
        nes will have a link.

        Patch by allen. 

diffs (98 lines):

diff -r 83db1f514e3b -r 65a2845c6b95 cgi-bin/LJ/Widget/Login.pm
--- a/cgi-bin/LJ/Widget/Login.pm        Mon Apr 18 12:18:34 2011 +0800
+++ b/cgi-bin/LJ/Widget/Login.pm        Mon Apr 18 12:22:30 2011 +0800
@@ -54,8 +54,9 @@ sub render_body {
     $ret .= "<input type='hidden' name='response' class='lj_login_response' 
value='' />\n";
 
     my $referer = BML::get_client_header('Referer');
+    my $eh_ref;
     if ($isloginpage && $opts{get_ret} == 1 && $referer) {
-        my $eh_ref = LJ::ehtml($referer);
+        $eh_ref = LJ::ehtml($referer);
         $ret .= "<input type='hidden' name='ref' value='$eh_ref' />\n";
     }
 
@@ -96,10 +97,14 @@ sub render_body {
         my $secure = "<p>";
         $secure .= LJ::img( 'ssl_locked', '', { class => 'secure-image' } );
         $secure .= LJ::Lang::ml('/login.bml.login.secure') . " | <a 
href='$LJ::SITEROOT/login?nojs=1'>" . LJ::Lang::ml('/login.bml.login.standard') 
. "</a></p>";
-
+        
+        # make sure the returnto value gets passed to openid
+        my $openid_args = $opts{returnto} ? "?returnto=" . 
LJ::ehtml($opts{returnto}) : $eh_ref ? "?returnto=" .  LJ::eurl($referer) : "";
         $ret .= "<p><input name='action:login' type='submit' value='"
                 . LJ::Lang::ml('/login.bml.login.btn.login') 
-                . "' tabindex='14' /> <a href='$LJ::SITEROOT/openid/' 
class='small-link' tabindex='15'>" 
+                . "' tabindex='14' /> <a href='$LJ::SITEROOT/openid/"
+                . $openid_args 
+                . "' class='small-link' tabindex='15'>" 
                 . LJ::Lang::ml('/login.bml.login.openid') 
                 . "</a></p>";
 
diff -r 83db1f514e3b -r 65a2845c6b95 htdocs/openid/index.bml
--- a/htdocs/openid/index.bml   Mon Apr 18 12:18:34 2011 +0800
+++ b/htdocs/openid/index.bml   Mon Apr 18 12:22:30 2011 +0800
@@ -65,6 +65,23 @@ p?>
 
    <div style='padding: 0.4em; margin-left: 25px; margin-right: 25px; width: 
auto; text-align: center; background: #ccc; border: #000'>
 <form method='post' action='login' style='display:inline; 
width:auto'><nobr><b><?_ml .login.openid_url _ml?></b> <input class='sexy' 
id='openid_url' name="openid_url" size='30' />
+<?_code {
+    
+    use vars qw(%GET);
+
+    my $continue_to = $GET{returnto} || BML::get_client_header('Referer');
+
+    if ( $continue_to ) {
+        return LJ::html_hidden( { 
+            name => 'continue_to',
+            value => LJ::ehtml($continue_to),
+        } );
+    } else {
+        return "";
+    }
+}
+
+_code?>
 <input style='background: #ff6200; color: #fff;' type='submit' value='<?_ml 
.login.submit _ml?>' /></nobr><br /><?_ml .login.example _ml?></form></div>
 
 <?h1 <?_ml .main.openid_other_sites _ml?> h1?>
diff -r 83db1f514e3b -r 65a2845c6b95 htdocs/openid/login.bml
--- a/htdocs/openid/login.bml   Mon Apr 18 12:18:34 2011 +0800
+++ b/htdocs/openid/login.bml   Mon Apr 18 12:22:30 2011 +0800
@@ -82,12 +82,18 @@ _c?>
         my $redirect = "$LJ::SITEROOT/login";
         # handle the continue_to url, if it's a valid URL to redirect to.
         my $continue_to = $GET{'continue_to'};
-        if ( $continue_to && DW::Controller::validate_redirect_url( 
$continue_to ) ) {
-            # if the account is validated, then go ahead and redirct
-            if ( $u->is_validated ) {
-                $redirect = $continue_to;
-            } else {
-                $redirect .= "?continue_to=" . LJ::eurl( $continue_to );
+        if ( $continue_to ) {
+            # some pages return a relative url
+            if ($continue_to =~ /^\//) {
+                $continue_to = $LJ::SITEROOT . $continue_to;
+            }
+            if ( DW::Controller::validate_redirect_url( $continue_to ) ) {
+                # if the account is validated, then go ahead and redirct
+                if ( $u->is_validated ) {
+                    $redirect = $continue_to;
+                } else {
+                    $redirect .= "?continue_to=" . LJ::eurl( $continue_to );
+                }
             }
         }
         return BML::redirect( $redirect );
diff -r 83db1f514e3b -r 65a2845c6b95 schemes/common.tt
--- a/schemes/common.tt Mon Apr 18 12:18:34 2011 +0800
+++ b/schemes/common.tt Mon Apr 18 12:22:30 2011 +0800
@@ -97,7 +97,7 @@ the same terms as Perl itself.  For a co
     <table summary='' id='login-table'>
     [%- -%]<tr><td><label for='login_user'>[% 
'sitescheme.accountlinks.login.username' | ml %]</label></td>
     [%- -%]<td class='input-cell' colspan='2'><input name="user" 
id="login_user" size="20" maxlength="27" tabindex="1" aria-required="true" />
-    [%- %] <a href='[% site.root %]/openid/' tabindex=5>[% 
'sitescheme.accountlinks.login.openid' | ml %]</a></td></tr>
+    [%- %] <a href='[% site.root %]/openid/[% IF get.returnto %]?returnto=[% 
get.returnto | html %][% END %]' tabindex=5>[% 
'sitescheme.accountlinks.login.openid' | ml %]</a></td></tr>
     [%- -%]<tr><td><label for='login_password'>[% 
'sitescheme.accountlinks.login.password' | ml %]</label></td>
     [%- -%]<td class='input-cell' colspan='2'><input type="password" 
name="password" id="login_password" size="20" tabindex="2" aria-required="true">
     [%- %] <a href='[% site.root %]/lostinfo' tabindex=6>[% 
'sitescheme.accountlinks.login.forgotpassword' | ml %]</a></td></tr>
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to