[Jifty-commit] r3604 - in jifty/trunk:
lib/Jifty/Plugin/Authentication
lib/Jifty/Plugin/Authentication/Facebook
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Jul 3 03:22:44 EDT 2007
Author: trs
Date: Tue Jul 3 03:22:43 2007
New Revision: 3604
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook.pm
jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/Dispatcher.pm
jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/View.pm
Log:
r24977 at zot: tom | 2007-07-03 03:04:34 -0400
More pod, forceable login
Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook.pm Tue Jul 3 03:22:43 2007
@@ -10,6 +10,12 @@
Jifty::Plugin::Authentication::Facebook
+=head2 DESCRIPTION
+
+Provides standalone Facebook authentication for your Jifty application.
+It adds the columns C<facebook_name>, C<facebook_uid>, C<facebook_session>,
+and C<facebook_session_expires> to your User model.
+
=head1 SYNOPSIS
In your jifty config.yml under the C<framework> section:
@@ -19,14 +25,22 @@
api_key: xxx
secret: xxx
-You may set any options which the C<new> method of
-L<WWW::Facebook::API> understands.
+You may set any options which the C<new> method of L<WWW::Facebook::API>
+understands.
-=head2 DESCRIPTION
+In your User model, you'll need to include the line
-Provides Facebook authentication for your Jifty application.
-It adds the columns C<facebook_name>, C<facebook_uid>, C<facebook_session>,
-and C<facebook_session_expires> to your C<User> model class.
+ use Jifty::Plugin::Authentication::Facebook::Mixin::Model::User;
+
+B<after> your schema definition (which may be empty). You may also wish
+to include
+
+ sub _brief_description { 'facebook_name' }
+
+To use the user's Facebook name as their description.
+
+See L<Jifty::Plugin::Authentication::Facebook::View> for the provided templates
+and L<Jifty::Plugin::Authentication::Facebook::Dispatcher> for the URLs handled.
=cut
@@ -63,4 +77,20 @@
return $api;
}
+=head2 get_login_url
+
+Gets the login URL, preserving continuations
+
+=cut
+
+sub get_login_url {
+ my $self = shift;
+ my $next = '/facebook/callback';
+
+ if ( Jifty->web->request->continuation ) {
+ $next .= '?J:C=' . Jifty->web->request->continuation->id;
+ }
+ return $self->api->get_login_url( next => $next );
+}
+
1;
Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/Dispatcher.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/Dispatcher.pm Tue Jul 3 03:22:43 2007
@@ -16,6 +16,8 @@
=head2 before '/facebook/callback'
+Handles the login callback. You probably don't need to worry about this.
+
=cut
before '/facebook/callback' => run {
@@ -34,8 +36,22 @@
}
};
+=head2 before '/facebook/force_login'
+
+Redirects user to the Facebook login page. Useful if you want to skip
+prompting the user to login on your app.
+
+=cut
+
+before '/facebook/force_login' => run {
+ my ($plugin) = Jifty->find_plugin('Jifty::Plugin::Authentication::Facebook');
+ Jifty->web->_redirect( $plugin->get_login_url );
+};
+
=head2 before '/facebook/logout'
+Directing a user here will log him out of the app and Facebook.
+
=cut
before '/facebook/logout' => run {
Modified: jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/View.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/View.pm (original)
+++ jifty/trunk/lib/Jifty/Plugin/Authentication/Facebook/View.pm Tue Jul 3 03:22:43 2007
@@ -10,21 +10,20 @@
=head1 DESCRIPTION
-Provides the Facebook login regions for L<Jifty::Plugin::Authentication::Facebook>
+Provides the Facebook login fragment for L<Jifty::Plugin::Authentication::Facebook>
-=cut
+=head2 /facebook/login
-template 'facebook/login' => sub {
- my ($plugin) = Jifty->find_plugin('Jifty::Plugin::Authentication::Facebook');
- my $next = '/facebook/callback';
+Calling C<show> on this fragment will include the standard Facebook button
+used for web login.
- if ( Jifty->web->request->continuation ) {
- $next .= '?J:C=' . Jifty->web->request->continuation->id;
- }
+=cut
+template '/facebook/login' => sub {
+ my ($plugin) = Jifty->find_plugin('Jifty::Plugin::Authentication::Facebook');
div {{ id is 'facebook_login' };
span { _("Login to Facebook now to get started!") };
- a {{ href is $plugin->api->get_login_url( next => $next ) };
+ a {{ href is $plugin->get_login_url };
img {{ src is 'http://static.ak.facebook.com/images/devsite/facebook_login.gif', border is '0' }};
};
};
More information about the Jifty-commit
mailing list