mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2012-07-21 02:25 am

[dw-free] Routing controller doesn't set domain cookie

[commit: http://hg.dwscoalition.org/dw-free/rev/1bfe3ee0a558]

http://bugs.dwscoalition.org/show_bug.cgi?id=4454

Add domain cookie bounces in a case they didn't happen

Patch by [personal profile] allen.

Files modified:
  • cgi-bin/DW/Controller.pm
--------------------------------------------------------------------------------
diff -r 156e2b39671c -r 1bfe3ee0a558 cgi-bin/DW/Controller.pm
--- a/cgi-bin/DW/Controller.pm	Fri Jul 20 19:21:20 2012 -0700
+++ b/cgi-bin/DW/Controller.pm	Fri Jul 20 19:29:50 2012 -0700
@@ -69,6 +69,10 @@
 # - privcheck => $privs -- user must be logged in and have at least one priv of
 #                          the ones in this arrayref.
 #                          Example: [ "faqedit:guides", "faqcat", "admin:*" ]
+# - skip_domsess => 1 -- (for user domains) don't redirect if there is no domain
+#                      login cookie
+# - skip_domsess => 0 -- (for user domains) do redirect for the user domain 
+#                        cookie (default)
 #
 # Returns one of:
 # - 0, $error_text (if there's an error)
@@ -97,13 +101,23 @@
     # 'anonymous' pages must declare themselves, else we assume that a remote is
     # necessary as most pages require a user
     $vars->{u} = $vars->{remote} = LJ::get_remote();
+    
+    my $r = DW::Request->get;
+
+    # check to see if we need to do a bounce to set the domain cookie
+    unless ( $r->did_post || $args{skip_domsess} ) {
+        my $burl = LJ::remote_bounce_url();
+        if ( $burl ) {
+            return $fail->( $r->redirect( $burl ) );
+        }
+    }
+
     unless ( $args{anonymous} ) {
         $vars->{remote}
             or return $fail->( needlogin() );
     }
 
     # if they can specify a user argument, try to load that
-    my $r = DW::Request->get;
     if ( $args{specify_user} ) {
         # use 'user' argument if specified, default to remote
         $vars->{u} = LJ::load_user( $r->get_args->{user} ) || $vars->{remote}
--------------------------------------------------------------------------------