Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r19439: LJSUP-9234: Redirect to login page if vi...

Committer: gariev
LJSUP-9234: Redirect to login page if viewing non-public friends group

U   trunk/cgi-bin/LJ/ControlStrip.pm
U   trunk/cgi-bin/LJ/Request.pm
U   trunk/cgi-bin/LJ/S2/EntryPage.pm
U   trunk/cgi-bin/LJ/S2/FriendsPage.pm
U   trunk/cgi-bin/LJ/S2/ReplyPage.pm
U   trunk/cgi-bin/weblib.pl
Modified: trunk/cgi-bin/LJ/ControlStrip.pm
===================================================================
--- trunk/cgi-bin/LJ/ControlStrip.pm	2011-07-05 10:59:13 UTC (rev 19438)
+++ trunk/cgi-bin/LJ/ControlStrip.pm	2011-07-05 11:35:57 UTC (rev 19439)
@@ -15,12 +15,8 @@
 
     my $remote = LJ::get_remote();
     my $journal = LJ::load_user($user);
+    my $uri = LJ::eurl( LJ::Request->current_page_url );
 
-    my $args = scalar LJ::Request->args;
-    my $querysep = $args ? "?" : "";
-    my $uri = "http://" . LJ::Request->header_in("Host") . LJ::Request->uri . $querysep . $args;
-    $uri = LJ::eurl($uri);
-
     my $data_remote = {};
     my $data_journal = {
         user => $journal->{user},

Modified: trunk/cgi-bin/LJ/Request.pm
===================================================================
--- trunk/cgi-bin/LJ/Request.pm	2011-07-05 10:59:13 UTC (rev 19438)
+++ trunk/cgi-bin/LJ/Request.pm	2011-07-05 11:35:57 UTC (rev 19439)
@@ -307,6 +307,17 @@
     return $redirected;
 }
 
+sub current_page_url {
+    my $class = shift;
+
+    my $proto   = ($LJ::IS_SSL) ? "https" : "http"; 
+    my $host    = $class->header_in("Host");
+    my $uri     = $class->uri;
+    my $args    = $class->args;
+    my $querysep= ($args) ? "?" : "";
+    return "$proto://$host$uri$querysep$args";
+}
+
 =head2 Cleanup
 
     # clean internal state variables; this is a hack until we get a cleaner

Modified: trunk/cgi-bin/LJ/S2/EntryPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/EntryPage.pm	2011-07-05 10:59:13 UTC (rev 19438)
+++ trunk/cgi-bin/LJ/S2/EntryPage.pm	2011-07-05 11:35:57 UTC (rev 19439)
@@ -454,10 +454,7 @@
             LJ::Request->pnotes ('remote' => LJ::get_remote());
             return;
         } else {
-            my $host = LJ::Request->header_in("Host");
-            my $args = scalar LJ::Request->args;
-            my $querysep = $args ? "?" : "";
-            my $redir = LJ::eurl("http://$host$uri$querysep$args");
+            my $redir = LJ::eurl( LJ::Request->current_page_url );
             $opts->{'redir'} = "$LJ::SITEROOT/?returnto=$redir&errmsg=notloggedin";
             return;
         }

Modified: trunk/cgi-bin/LJ/S2/FriendsPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/FriendsPage.pm	2011-07-05 10:59:13 UTC (rev 19438)
+++ trunk/cgi-bin/LJ/S2/FriendsPage.pm	2011-07-05 11:35:57 UTC (rev 19439)
@@ -126,9 +126,15 @@
         my $public = $grp->{'is_public'};
         if ($bit && ($public || ($remote && $remote->{'user'} eq $user))) {
             $filter = (1 << $bit);
-        } elsif ($group_name){
-            $opts->{'badfriendgroup'} = 1;
-            return 1;
+        } elsif ($group_name) {
+            if ($remote) {
+                $opts->{'badfriendgroup'} = 1;
+                return 1;
+            } else {
+                my $redir = LJ::eurl( LJ::Request->current_page_url );
+                $opts->{'redir'} = "$LJ::SITEROOT/?returnto=$redir&errmsg=notloggedin";
+                return;
+            }
         }
     }
 

Modified: trunk/cgi-bin/LJ/S2/ReplyPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/ReplyPage.pm	2011-07-05 10:59:13 UTC (rev 19438)
+++ trunk/cgi-bin/LJ/S2/ReplyPage.pm	2011-07-05 11:35:57 UTC (rev 19439)
@@ -66,12 +66,7 @@
         my $errref;
         $comment = LJ::Comment->new($u, dtalkid => $editid);
         unless ($remote) {
-            my $host = LJ::Request->header_in("Host");
-            my $uri = LJ::Request->uri;
-            my $args = scalar LJ::Request->args;
-            my $querysep = $args ? "?" : "";
-            my $redir = LJ::eurl("http://$host$uri$querysep$args");
-
+            my $redir = LJ::eurl( LJ::Request->current_page_url );
             $opts->{'redir'} = "$LJ::SITEROOT/?returnto=$redir&errmsg=notloggedin";
             return;
         }

Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2011-07-05 10:59:13 UTC (rev 19438)
+++ trunk/cgi-bin/weblib.pl	2011-07-05 11:35:57 UTC (rev 19439)
@@ -1898,11 +1898,7 @@
     return "" unless $show_strip;
 
     my $remote = LJ::get_remote();
-
-    my $args = scalar LJ::Request->args;
-    my $querysep = $args ? "?" : "";
-    my $uri = "http://" . LJ::Request->header_in("Host") . LJ::Request->uri . $querysep . $args;
-    $uri = LJ::eurl($uri);
+    my $uri = LJ::eurl( LJ::Request->current_page_url );
     my $create_link = LJ::run_hook("override_create_link_on_navstrip", $journal) || "<a href='$LJ::SITEROOT/create.bml'>" . BML::ml('web.controlstrip.links.create', {'sitename' => $LJ::SITENAMESHORT}) . "</a>";
 
     # Build up some common links

Tags: gariev, livejournal, pl, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments