Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r17096: LJSUP-6137 (FaceBook authorization. Serv...

Committer: ailyin
LJSUP-6137 (FaceBook authorization. Server side): disable flags
U   trunk/cgi-bin/LJ/Identity/OpenID.pm
U   trunk/cgi-bin/LJ/Identity.pm
U   trunk/cgi-bin/LJ/Talk/Author/OpenID.pm
U   trunk/cgi-bin/LJ/Talk/Author.pm
U   trunk/cgi-bin/LJ/Talk/Post.pm
U   trunk/cgi-bin/LJ/Talk.pm
U   trunk/htdocs/identity/callback-openid.bml
U   trunk/htdocs/identity/login.bml
Modified: trunk/cgi-bin/LJ/Identity/OpenID.pm
===================================================================
--- trunk/cgi-bin/LJ/Identity/OpenID.pm	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/cgi-bin/LJ/Identity/OpenID.pm	2010-08-09 05:20:58 UTC (rev 17096)
@@ -9,6 +9,10 @@
 sub pretty_type { 'OpenID' }
 sub short_code { 'openid' }
 
+sub enabled {
+    return LJ::OpenID->consumer_enabled;
+}
+
 sub url {
     my ($self) = @_;
     return $self->value;

Modified: trunk/cgi-bin/LJ/Identity.pm
===================================================================
--- trunk/cgi-bin/LJ/Identity.pm	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/cgi-bin/LJ/Identity.pm	2010-08-09 05:20:58 UTC (rev 17096)
@@ -172,6 +172,12 @@
 for the profile page of this user. Used in htdocs/userinfo.bml. It is
 suggested that implementations use LJ::Lang::ml for i18n.
 
+=item *
+
+enabled: return a boolean value indicating that this identity type is
+enabled on the server. Disabled identity types are not displayed to the
+user.
+
 =back
 
 =cut
@@ -186,4 +192,6 @@
 sub ljuser_display_params   { Carp::confess 'Invalid identity type' }
 sub profile_window_title    { Carp::confess 'Invalid identity type' }
 
+sub enabled { 1 }
+
 1;

Modified: trunk/cgi-bin/LJ/Talk/Author/OpenID.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk/Author/OpenID.pm	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/cgi-bin/LJ/Talk/Author/OpenID.pm	2010-08-09 05:20:58 UTC (rev 17096)
@@ -3,6 +3,10 @@
 
 use base qw(LJ::Talk::Author);
 
+sub enabled {
+    return LJ::Identity::OpenID->enabled;
+}
+
 sub display_params {
     my ($class, $opts) = @_;
 

Modified: trunk/cgi-bin/LJ/Talk/Author.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk/Author.pm	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/cgi-bin/LJ/Talk/Author.pm	2010-08-09 05:20:58 UTC (rev 17096)
@@ -56,6 +56,15 @@
 
 =head2 (Purely) virtual
 
+=head3 enabled
+
+Return a boolean value indicating that this author choice is enabled on the
+server. Disabled choices are not displayed to the user.
+
+=cut
+
+sub enabled { 1 }
+
 =head3 short_code
 
 Return the "short code" for this author choice. It is used by the

Modified: trunk/cgi-bin/LJ/Talk/Post.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk/Post.pm	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/cgi-bin/LJ/Talk/Post.pm	2010-08-09 05:20:58 UTC (rev 17096)
@@ -303,7 +303,7 @@
     my $author_class = LJ::Talk::Author->get_handler($form->{'usertype'});
 
     # whoops, a bogus usertype value. no way.
-    unless ($author_class) {
+    unless ( $author_class && $author_class->enabled ) {
         return $bmlerr->('error.invalidform');
     }
 

Modified: trunk/cgi-bin/LJ/Talk.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk.pm	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/cgi-bin/LJ/Talk.pm	2010-08-09 05:20:58 UTC (rev 17096)
@@ -1493,6 +1493,8 @@
 
     my @author_options;
     foreach my $author_class (LJ::Talk::Author->all) {
+        next unless $author_class->enabled;
+
         my $params = $author_class->display_params($opts);
         $params->{'short_code'} = $author_class->short_code;
         push @author_options, $params;

Modified: trunk/htdocs/identity/callback-openid.bml
===================================================================
--- trunk/htdocs/identity/callback-openid.bml	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/htdocs/identity/callback-openid.bml	2010-08-09 05:20:58 UTC (rev 17096)
@@ -19,6 +19,9 @@
     my $returl_fail = LJ::Request->get_param('ret_fail') ||
                       $returl ||$LJ::SITEROOT;
 
+    return LJ::Request->redirect($returl_fail)
+        unless LJ::Identity::OpenID->enabled;
+
     my %get_params = LJ::Request->get_params;
     my $csr = LJ::Identity::OpenID->consumer(\%get_params);
 

Modified: trunk/htdocs/identity/login.bml
===================================================================
--- trunk/htdocs/identity/login.bml	2010-08-09 04:04:46 UTC (rev 17095)
+++ trunk/htdocs/identity/login.bml	2010-08-09 05:20:58 UTC (rev 17096)
@@ -20,7 +20,7 @@
         my $idtype = LJ::Request->post_param('type');
         my $idclass = LJ::Identity->find_class($idtype);
 
-        if ($idclass) {
+        if ($idclass && $idclass->enabled) {
             $idclass->attempt_login(\@errors,
                 'returl_fail' => "$thispage?type=$idtype",
             );
@@ -39,6 +39,9 @@
 
     my @types;
     foreach my $type (@LJ::IDENTITY_TYPES) {
+        my $idclass = LJ::Identity->find_class($type);
+        next unless $idclass->enabled;
+
         push @types, {
             'type' => $type,
             'ml_tab_heading' => LJ::Lang::ml(".tab.$type"),

Tags: andy, bml, livejournal, 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