Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r19528: LJSUP-9334: New auth system for external...

Committer: amyshkin
LJSUP-9334: New auth system for external domains (livejournal.sg)
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-07-26 07:40:45 UTC (rev 19527)
+++ trunk/cgi-bin/LJ/User.pm	2011-07-26 08:25:28 UTC (rev 19528)
@@ -285,7 +285,7 @@
     }
 
     # user subdomains
-    if ($LJ::USER_DOMAIN && $url =~ m!^http://([\w-]+)\.\Q$LJ::USER_DOMAIN\E/?$!) {
+    if ($LJ::USER_DOMAIN && $url =~ m!^http://([\w-]+)\.\Q$LJ::USER_DOMAIN\E(/.*|/)?$!) {
         my $u = LJ::load_user($1);
         return $u if $u;
     }
@@ -318,6 +318,7 @@
 
     my $key = "domain:$host";
     my $userid = LJ::MemCache::get($key);
+
     unless (defined $userid) {
         my $db = LJ::get_db_reader();
         ($userid) = $db->selectrow_array(qq{SELECT userid FROM domains WHERE domain=?}, undef, $host);
@@ -325,7 +326,8 @@
         my $expire = time() + 1800;
         LJ::MemCache::set($key, $userid, $expire);
     }
-    return ($userid) ? LJ::load_userid($userid) : undef;
+
+    return ($userid) if LJ::load_userid($userid);
 }
 
 # returns LJ::User class of a random user, undef if we couldn't get one
@@ -6230,6 +6232,22 @@
 }
 
 # <LJFUNC>
+# name: LJ::trusted
+# des: Checks to see if the remote user can use javascript in S2 layers.
+# returns: boolean; 1 if remote user can use javascript
+# args: userid
+# des-userid: id of user to check
+# </LJFUNC>
+sub trusted {
+    my ($userid) = @_;
+
+    my $u = LJ::load_userid($userid);
+    return 0 unless $u;
+
+    return $u->prop('javascript');
+}
+
+# <LJFUNC>
 # name: LJ::can_view
 # des: Checks to see if the remote user can view a given journal entry.
 #      <b>Note:</b> This is meant for use on single entries at a time,
@@ -9964,8 +9982,7 @@
 # returns: hashref containing 'user' and 'userid' if valid user, else
 #          undef.
 # </LJFUNC>
-sub get_remote
-{
+sub get_remote {
     my $opts = ref $_[0] eq "HASH" ? shift : {};
     return $LJ::CACHE_REMOTE if $LJ::CACHED_REMOTE && ! $opts->{'ignore_ip'};
 
@@ -9987,10 +10004,11 @@
     # in and set it, or set it with a free account, then we give them
     # the invalid cookies error.
     my $tried_fast = 0;
-    my $sessobj = LJ::Session->session_from_cookies(tried_fast   => \$tried_fast,
-                                                    redirect_ref => \$LJ::CACHE_REMOTE_BOUNCE_URL,
-                                                    ignore_ip    => $opts->{ignore_ip},
-                                                    );
+    my $sessobj = LJ::Session->session_from_cookies(
+        tried_fast   => \$tried_fast,
+        redirect_ref => \$LJ::CACHE_REMOTE_BOUNCE_URL,
+        ignore_ip    => $opts->{ignore_ip},
+    );
 
     my $u = $sessobj ? $sessobj->owner : undef;
 

Tags: livejournal, pm, zilogic
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