[Catalyst-commits] r12127 - trunk/examples/CatalystAdvent/root/2009/pen

zamolxes at dev.catalyst.perl.org zamolxes at dev.catalyst.perl.org
Tue Dec 1 19:30:10 GMT 2009


Author: zamolxes
Date: 2009-12-01 19:30:09 +0000 (Tue, 01 Dec 2009)
New Revision: 12127

Modified:
   trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod
Log:
formatting


Modified: trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod
===================================================================
--- trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod	2009-12-01 19:24:06 UTC (rev 12126)
+++ trunk/examples/CatalystAdvent/root/2009/pen/fbconnect.pod	2009-12-01 19:30:09 UTC (rev 12127)
@@ -2,11 +2,24 @@
 
 L<Catalyst::Authentication::Credential::FBConnect> offers an easy way to grab the credential identifier, session key and session expires from a user on Facebook.
 
-Creaza un $c->user cu metodele:
+
+You'll have the following accessors in C<$c->user>
+
+=over
+
+=item
+
 session_uid
+
+=item
+
 session_key
+
+=item
+
 session_expires
 
+=back
 
 =head1 Instalation
 
@@ -24,156 +37,135 @@
 =head1 Getting it done
 
 
-=begin pod::xhtml
 
-<p>
+ package MyApp;
+ 
+ __PACKAGE__->config( 'authentication' => {
+     default_realm => 'facebook',
+     realms => {
+         facebook => {
+             credential => {
+                 class       => 'FBConnect',
+                 api_key     => 'my_api_key',
+                 secret      => 'my_secret',
+                 app_name    => 'my_app_name',
+             }
+         },
+         dbic => {
+             credential => {
+                 class       => 'Password', 
+                 password_type => 'none',
+             },
+             store => {
+                 class       => 'DBIx::Class',
+                 user_class  => 'DB::User',
+                 id_field    => 'user_id'
+             }
+         }
+     }
+ } );
 
-<pre>
-package MyApp;
 
-__PACKAGE__->config( 'authentication' => {
-    default_realm => 'facebook',
-    realms => {
-        facebook => {
-            credential => {
-                class       => 'FBConnect',
-                api_key     => 'my_api_key',
-                secret      => 'my_secret',
-                app_name    => 'my_app_name',
-            }
-        },
-        dbic => {
-            credential => {
-                class       => 'Password', 
-                password_type => 'none',
-            },
-            store => {
-                class       => 'DBIx::Class',
-                user_class  => 'DB::User',
-                id_field    => 'user_id'
-            }
-        }
-    }
-} );
 
+ package MyApp::Schema::Result::User;
+ use strict;
+ use warnings;
+ 
+ use base 'DBIx::Class';
+ 
+ __PACKAGE__->table( 'users' );
+ __PACKAGE__->add_columns(
+     user_id => {
+         data_type           => 'integer',
+         is_auto_increment   => 1,
+     },
+     email => {
+         data_type           => 'varchar',
+         is_nullable         => 1
+     },
+     password => {
+         data_type           => 'varchar',
+         is_nullable         => 1
+     },
+     credential_identifier => {
+         data_type           => 'varchar',
+         is_nullable         => 1
+     },
+     credential_source => {
+         data_type           => 'varchar',
+         is_nullable         => 1
+     },
+ );
+ 
+ __PACKAGE__->set_primary_key( 'user_id' );
+ 
+ __PACKAGE__->add_unique_constraint( [ qw/ credential_identifier credential_source / ] );
+ 
+ 
+ 1;
 
 
-package MyApp::Schema::Result::User;
-use strict;
-use warnings;
 
-use base 'DBIx::Class';
+ package MyApp::Controller::FBConnect;
+ use strict;
+ use warnings;
+ 
+ use base 'Catalyst::Controller';
+ 
+ sub login : Path('/login/facebook') {
+     my ($self, $c) = @_;
+ 
+     if( $c->authenticate( {}, 'facebook' ) ) {
+         my $user = $c->model('DB::User')->find_or_create( {
+             credential_identifier   => $c->user->session_uid,
+             credential_source       => 'facebook',
+         } );
+ 
+         $c->authenticate( {
+             credential_identifier   => $user->credential_identifier,
+             credential_source       => 'facebook'
+         }, 'dbic' ) or die "Login failed";
+     }
+ }
+ 
+ 
+ 1;
 
-__PACKAGE__->table( 'users' );
-__PACKAGE__->add_columns(
-    user_id => {
-        data_type           => 'integer',
-        is_auto_increment   => 1,
-    },
-    email => {
-        data_type           => 'varchar',
-        is_nullable         => 1
-    },
-    password => {
-        data_type           => 'varchar',
-        is_nullable         => 1
-    },
-    credential_identifier => {
-        data_type           => 'varchar',
-        is_nullable         => 1
-    },
-    credential_source => {
-        data_type           => 'varchar',
-        is_nullable         => 1
-    },
-);
 
-__PACKAGE__->set_primary_key( 'user_id' );
-
-__PACKAGE__->add_unique_constraint( [ qw/ credential_identifier credential_source / ] );
-
-
-1;
-
-
-
-package MyApp::Controller::FBConnect;
-use strict;
-use warnings;
-
-use base 'Catalyst::Controller';
-
-sub login : Path('/login/facebook') {
-    my ($self, $c) = @_;
-
-    if( $c->authenticate( {}, 'facebook' ) ) {
-        my $user = $c->model('DB::User')->find_or_create( {
-            credential_identifier   => $c->user->session_uid,
-            credential_source       => 'facebook',
-        } );
-
-        $c->authenticate( {
-            credential_identifier   => $user->credential_identifier,
-            credential_source       => 'facebook'
-        }, 'dbic' ) or die "Login failed";
-    }
-}
-
-
-1;
-
-</pre>
-
-</p>
-
-=end pod::xhtml
-
-
 You can also assign a facebook account to an already existing account.
 
-=begin pod:xhtml
 
-<p><pre>
+ #somewhere in a password required login: $c->authenticate( { email => $email, password => $password }, 'foo' );
+ 
+ package MyApp::Controller::FBconnect;
+ use strict;
+ use warnings;
+ 
+ sub assign : Path('/assign/facebook') {
+     my ($self, $c) = @_;
+ 
+     my $user = $c->user if $c->user_in_realm('foo');
+     if( $c->authenticate( {}, 'facebook' ) ) {
+         $user->update( {
+             credential_identifier   => $c->user->session_uid,
+             credential_source       => 'facebook',
+         } );
+ 
+         $c->authenticate( {
+             credential_identifier   => $user->credential_identifier,
+             credential_source       => 'facebook'
+         }, 'dbic' ) or die "Login failed";
+     }
+         
+ }
 
-#somewhere in a password required login: $c->authenticate( { email => $email, password => $password }, 'foo' );
 
-package MyApp::Controller::FBconnect;
-use strict;
-use warnings;
 
-sub assign : Path('/assign/facebook') {
-    my ($self, $c) = @_;
 
-    my $user = $c->user if $c->user_in_realm('foo');
-    if( $c->authenticate( {}, 'facebook' ) ) {
-        $user->update( {
-            credential_identifier   => $c->user->session_uid,
-            credential_source       => 'facebook',
-        } );
-
-        $c->authenticate( {
-            credential_identifier   => $user->credential_identifier,
-            credential_source       => 'facebook'
-        }, 'dbic' ) or die "Login failed";
-    }
-        
-}
-
-</pre></p>
-
-
-=end pod:xhtml
-
-
 This practicaly gets you the uid from Facebook. This can be used later on with L<WWW::Facebook::API>.
 
 Here's some example code to actualy use L<WWW::Facebook::API>
 
-=begin pod::xhtml
-    
-<p>
-
-<pre>
     my $client = WWW::Facebook::API->new(
         desktop         => 0,
         api_key         => 'my_api_key'
@@ -190,36 +182,7 @@
     my $friends = $client->friends->get(
         uid => $c->user->credential_identifier
     );
-</pre>
 
-</p>
 
 
-=end pod::xhtml
-
-
 More about this can be found in the L<WWW::Facebook::API> docs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-




More information about the Catalyst-commits mailing list