package Catalyst::Authentication::Credential::FBConnect;
use Moose;
-use namespace::autoclean;
-
-has debug => ( is => 'ro' );
-has key => ( is => 'ro' );
-has secret => ( is => 'ro' );
-has app_name => ( is => 'ro' );
-has fbconnect => ( is => 'ro', lazy_build => 1, init_arg => undef );
-
-has realm => ( is => 'ro', required => 1, weak_ref => 1 );
-
+use MooseX::Types::Moose qw/ Bool /;
+use MooseX::Types::Common::String qw/ NonEmptySimpleStr /;
use WWW::Facebook::API;
use Catalyst::Exception ();
+use namespace::autoclean;
+
+has debug => ( is => 'ro', isa => Bool, );
+has api_key => ( is => 'ro', isa => NonEmptySimpleStr, required => 1 );
+has secret => ( is => 'ro', isa => NonEmptySimpleStr, required => 1 );
+has app_name => ( is => 'ro', isa => NonEmptySimpleStr, required => 1 );
+has fbconnect => ( is => 'ro', lazy_build => 1, init_arg => undef, isa => 'WWW::Facebook::API' );
sub BUILDARGS {
my ($class, $config, $c, $realm) = @_;
- return {
- %{ $config },
- %{ $realm->{config} }, # Ewww, gross hack to steal the realms config too.
- realm => $realm,
- };
+ return $config;
}
sub BUILD {
sub _build_fbconnect {
my $self = shift;
+
WWW::Facebook::API->new(
desktop => 0,
map { $_ => $self->$_() } qw/ app_name api_key secret /
return;
}
else {
-
- $c->res->redirect( $self->fbconnect->get_login_url( next => $c->uri_for( $c->action ) ) );
+ $c->res->redirect( $self->fbconnect->get_login_url( next => $c->uri_for( $c->action, $c->req->captures, @{ $c->req->args } ) ) );
}
}
In myapp.conf
- <Plugin::Authentication>
- default_realm facebook
- <realms>
- <facebook>
+ <Plugin::Authentication>
+ default_realm facebook
+ <realms>
+ <facebook>
<credential>
- class FBConnect
- </credential>
- key my_app_key
- secret my_app_secret
- app_name my_app_name
- </facebook>
- </realms>
-</Plugin::Authentication>
+ class FBConnect
+ api_key my_app_key
+ secret my_app_secret
+ app_name my_app_name
+ </credential>
+ </facebook>
+ </realms>
+ </Plugin::Authentication>
In controller code,