[Jifty-commit] r3314 - in jifty/trunk/lib/Jifty/Plugin:
Authentication/Password/Mixin/Model OpenID OpenID/Mixin/Model
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Jun 1 14:31:59 EDT 2007
Author: clkao
Date: Fri Jun 1 14:31:58 2007
New Revision: 3314
Added:
jifty/trunk/lib/Jifty/Plugin/OpenID/Mixin/
jifty/trunk/lib/Jifty/Plugin/OpenID/Mixin/Model/
jifty/trunk/lib/Jifty/Plugin/OpenID/Mixin/Model/User.pm
Modified:
jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Mixin/Model/User.pm
jifty/trunk/lib/Jifty/Plugin/OpenID/View.pm
Log:
* User model mixin for OpenID plugin.
* Make Authenticate::Password aware that there can be alternative
authentication systems.
* Make OpenID plugin work even when Authenticate::Password is
enabled.
Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Mixin/Model/User.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Mixin/Model/User.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Password/Mixin/Model/User.pm Fri Jun 1 14:31:58 2007
@@ -21,7 +21,6 @@
column password =>
- is mandatory,
is unreadable,
label is _('Password'),
type is 'varchar',
@@ -77,7 +76,8 @@
=head2 validate_password
-Makes sure that the password is six characters long or longer.
+Makes sure that the password is six characters long or longer, unless
+we have alternative means to authenticate.
=cut
@@ -85,6 +85,8 @@
my $self = shift;
my $new_value = shift;
+ return 1 if $self->_has_alternative_auth();
+
return ( 0, _('Passwords need to be at least six characters long') )
if length($new_value) < 6;
@@ -102,9 +104,17 @@
} else {
warn $self->id . " " .$self->email;
}
+}
+=head2 has_alternative_auth
-}
+If your model supports other means of authentication, you should have
+this method return true, so the C<password> field can optionally be
+null and authentication with password is disabled in that case.
+
+=cut
+
+sub has_alternative_auth { }
=head2 after_set_password
Added: jifty/trunk/lib/Jifty/Plugin/OpenID/Mixin/Model/User.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/lib/Jifty/Plugin/OpenID/Mixin/Model/User.pm Fri Jun 1 14:31:58 2007
@@ -0,0 +1,21 @@
+package Jifty::Plugin::OpenID::Mixin::Model::User;
+use strict;
+use warnings;
+use Jifty::DBI::Schema;
+use base 'Jifty::DBI::Record::Plugin';
+
+
+use Jifty::Plugin::OpenID::Record schema {
+
+column openid =>
+ type is 'text',
+ label is 'OpenID',
+ hints is q{You can use your OpenID to log in quickly and easily.},
+ is distinct,
+ is immutable;
+
+};
+
+sub has_alternative_auth { 1 }
+
+1;
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 1 14:31:58 2007
@@ -3,7 +3,7 @@
use warnings;
use Jifty::View::Declare -base;
-template 'login' => page {
+template 'openid/login' => page {
{ title is _ "Login with your OpenID" }
my $action = get('action');
@@ -34,7 +34,7 @@
}
};
-template 'create' => page {
+template 'openid/create' => page {
title is 'Set your username';
my ( $action, $next ) = get( 'action', 'next' );
More information about the Jifty-commit
mailing list