[Jifty-commit] r5536 - in jifty/trunk/lib/Jifty/Plugin/OpenID: .

Jifty commits jifty-commit at lists.jifty.org
Fri Jun 27 13:59:05 EDT 2008


Author: gugod
Date: Fri Jun 27 13:59:04 2008
New Revision: 5536

Modified:
   jifty/trunk/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm
   jifty/trunk/lib/Jifty/Plugin/OpenID/View.pm

Log:
When OpenID plugin needs to create a new user, instead of assuming
there's a "name" column in "User" model, it is better just reading all
the arguments from CreateUser action.

The only column that is assumed have in user model is "openid", which
is defined in the model mixin.

Now the CreateOpenIDUser action is basically doing a CreateUser
action, but with some extra conditions. For example, the value of
openid must not be read from user input, but needs to be retrieved
from the session.


Modified: jifty/trunk/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/OpenID/Action/CreateOpenIDUser.pm	Fri Jun 27 13:59:04 2008
@@ -35,21 +35,11 @@
 
 sub arguments {
     my $self = shift;
-    my $args = $self->SUPER::arguments;
-
-    my %fields = (
-        name => 1,
-    );
-
-    for ( keys %$args ){
-        delete $args->{$_} unless $fields{$_};
-    }
-
-    $args->{'name'}{'ajax_validates'} = 1;
+    my $args = $self->record_class->new->as_create_action->arguments;
+    delete $args->{openid};
     return $args;
 }
 
-
 =head2 take_action
 
 =cut
@@ -65,7 +55,7 @@
         return;
     }
 
-    my $user = Jifty->app_class("Model", "User")->new(current_user => Jifty->app_class("CurrentUser")->superuser );
+    my $user = $self->record_class->new(current_user => Jifty->app_class("CurrentUser")->superuser );
 
     $user->load_by_cols( openid => $openid );
 
@@ -74,7 +64,7 @@
         return;
     }
 
-    $user->create( openid => $openid, name => $self->argument_value('name') );
+    $user->create( openid => $openid, %{$self->argument_values} );
 
     if ( not $user->id ) {
         $self->result->error( "Something bad happened and we couldn't log you in.  Please try again later." );

Modified: jifty/trunk/lib/Jifty/Plugin/OpenID/View.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/OpenID/View.pm	(original)
+++ jifty/trunk/lib/Jifty/Plugin/OpenID/View.pm	Fri Jun 27 13:59:04 2008
@@ -61,7 +61,7 @@
         );
     };
     Jifty->web->form->start( call => $next );
-    render_param( $action, 'name', default_value => get('nickname') );
+    render_action($action);
     form_submit( label => _('Continue'), submit => $action );
     Jifty->web->form->end;
 };


More information about the Jifty-commit mailing list