1 package Catalyst::Authentication::Credential::FBConnect;
7 has _config => ( is => 'rw' );
8 has debug => ( is => 'rw' );
9 has key => ( is => 'rw' );
10 has secret => ( is => 'rw' );
11 has app_name => ( is => 'rw' );
12 has fbconnect => ( is => 'rw' );
14 use WWW::Facebook::API;
15 use Catalyst::Exception ();
18 my ($class, $config, $c, $realm) = @_;
20 my $self = { _config => {
27 $self->debug( $self->_config->{debug} );
29 $self->key( $self->_config->{key} );
30 $self->secret( $self->_config->{secret} );
31 $self->app_name( $self->_config->{app_name} );
33 $self->fbconnect( WWW::Facebook::API->new(
35 app_name => $self->app_name,
36 api_key => $self->key,
37 secret => $self->secret
44 my ($self, $c, $realm, $auth_info) = @_;
46 my $token = $c->req->method eq 'GET'
47 ? $c->req->query_params->{'auth_token'}
48 : $c->req->body_params->{'auth_token'};
50 if( defined $token ) {
52 $self->fbconnect->auth->get_session( $token );
55 session_uid => $self->fbconnect->session_uid,
56 session_key => $self->fbconnect->session_key,
57 session_expires => $self->fbconnect->session_expires
60 my $user_obj = $realm->find_user( $user, $c );
62 return $user_obj if ref $user_obj;
64 $c->log->debug( 'Verified FBConnect itentity failed' ) if $self->debug;
70 $c->res->redirect( $self->fbconnect->get_login_url( next => $c->uri_for( $c->action ) ) );
81 Catalyst::Authentication::Credential::FBConnect - Facebook credential for Catalyst::Plugin::Authentication framework.
94 Session::Store::FastMmap
95 Session::State::Cookie
101 <Plugin::Authentication>
102 default_realm facebook
113 </Plugin::Authentication>
118 sub facebook : Local {
121 if( $c->authenticate() ) {
122 #do something with $c->user
132 =item $c->user->session_uid
134 =item $c->user->session_key
136 =item $c->user->session_expires
142 Cosmin Budrica E<lt>cosmin@sinapticode.comE<gt>
144 Bogdan Lucaciu E<lt>bogdan@sinapticode.comE<gt>
148 Copyright (c) 2009 Sinapticode. All rights reserved
150 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.