1 package Catalyst::Authentication::Credential::FBConnect;
3 use namespace::autoclean;
5 has debug => ( is => 'ro' );
6 has key => ( is => 'ro' );
7 has secret => ( is => 'ro' );
8 has app_name => ( is => 'ro' );
9 has fbconnect => ( is => 'ro', lazy_build => 1, init_arg => undef );
11 has realm => ( is => 'ro', required => 1, weak_ref => 1 );
13 use WWW::Facebook::API;
14 use Catalyst::Exception ();
17 my ($class, $config, $c, $realm) = @_;
21 %{ $realm->{config} }, # Ewww, gross hack to steal the realms config too.
28 $self->fbconnect; # Ensure lazy value is built.
31 sub _build_fbconnect {
33 WWW::Facebook::API->new(
35 map { $_ => $self->$_() } qw/ app_name api_key secret /
40 my ($self, $c, $realm, $auth_info) = @_;
42 my $token = $c->req->method eq 'GET'
43 ? $c->req->query_params->{'auth_token'}
44 : $c->req->body_params->{'auth_token'};
46 if( defined $token ) {
48 $self->fbconnect->auth->get_session( $token );
51 session_uid => $self->fbconnect->session_uid,
52 session_key => $self->fbconnect->session_key,
53 session_expires => $self->fbconnect->session_expires
56 my $user_obj = $realm->find_user( $user, $c );
58 return $user_obj if ref $user_obj;
60 $c->log->debug( 'Verified FBConnect itentity failed' ) if $self->debug;
66 $c->res->redirect( $self->fbconnect->get_login_url( next => $c->uri_for( $c->action ) ) );
77 Catalyst::Authentication::Credential::FBConnect - Facebook credential for Catalyst::Plugin::Authentication framework.
90 Session::Store::FastMmap
91 Session::State::Cookie
97 <Plugin::Authentication>
98 default_realm facebook
109 </Plugin::Authentication>
114 sub facebook : Local {
117 if( $c->authenticate() ) {
118 #do something with $c->user
128 =item $c->user->session_uid
130 =item $c->user->session_key
132 =item $c->user->session_expires
138 Cosmin Budrica E<lt>cosmin@sinapticode.comE<gt>
140 Bogdan Lucaciu E<lt>bogdan@sinapticode.comE<gt>
144 Copyright (c) 2009 Sinapticode. All rights reserved
146 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.