fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-12-01 07:50 am

[dw-free] better organization of LJ functions

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

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

Move LJ::get_authas_user from ljlib.pl to LJ/User.pm. No package changes.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/User.pm
  • cgi-bin/ljlib.pl
--------------------------------------------------------------------------------
diff -r 4dc5918d25be -r d7e0d63ac3b5 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Thu Dec 01 15:46:56 2011 +0800
+++ b/cgi-bin/LJ/User.pm	Thu Dec 01 15:50:47 2011 +0800
@@ -7685,6 +7685,37 @@
     return $LJ::ACTIVE_JOURNAL;
 }
 
+# <LJFUNC>
+# name: LJ::get_authas_user
+# des: Given a username, will return a user object if remote is an admin for the
+#      username.  Otherwise returns undef.
+# returns: user object if authenticated, otherwise undef.
+# args: user
+# des-opts: Username of user to attempt to auth as.
+# </LJFUNC>
+sub get_authas_user {
+    my $user = $_[0];
+    return undef unless $user;
+
+    # get a remote
+    my $remote = LJ::get_remote();
+    return undef unless $remote;
+
+    # remote is already what they want?
+    return $remote if $remote->user eq $user;
+
+    # load user and authenticate
+    my $u = LJ::load_user($user);
+    return undef unless $u;
+    return undef unless $u->{clusterid};
+
+    # does $remote have admin access to $u?
+    return undef unless $remote->can_manage( $u );
+
+    # passed all checks, return $u
+    return $u;
+}
+
 # returns either $remote or the authenticated user that $remote is working with
 sub get_effective_remote {
     my $authas_arg = shift || "authas";
diff -r 4dc5918d25be -r d7e0d63ac3b5 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Thu Dec 01 15:46:56 2011 +0800
+++ b/cgi-bin/ljlib.pl	Thu Dec 01 15:50:47 2011 +0800
@@ -409,37 +409,6 @@
 }
 
 # <LJFUNC>
-# name: LJ::get_authas_user
-# des: Given a username, will return a user object if remote is an admin for the
-#      username.  Otherwise returns undef.
-# returns: user object if authenticated, otherwise undef.
-# args: user
-# des-opts: Username of user to attempt to auth as.
-# </LJFUNC>
-sub get_authas_user {
-    my $user = shift;
-    return undef unless $user;
-
-    # get a remote
-    my $remote = LJ::get_remote();
-    return undef unless $remote;
-
-    # remote is already what they want?
-    return $remote if $remote->user eq $user;
-
-    # load user and authenticate
-    my $u = LJ::load_user($user);
-    return undef unless $u;
-    return undef unless $u->{clusterid};
-
-    # does $remote have admin access to $u?
-    return undef unless $remote->can_manage( $u );
-
-    # passed all checks, return $u
-    return $u;
-}
-
-# <LJFUNC>
 # name: LJ::is_valid_authaction
 # des: Validates a shared secret (authid/authcode pair)
 # info: See [func[LJ::register_authaction]].
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org