fix Module::Install without . in @INC
[catagits/Catalyst-Plugin-Authentication.git] / lib / Catalyst / Plugin / Authentication.pm
index 07e33b3..ff8d4c2 100644 (file)
@@ -1,18 +1,16 @@
 package Catalyst::Plugin::Authentication;
 
-use base qw/Class::Accessor::Fast/;
-
-__PACKAGE__->mk_accessors(qw/_user/);
-
-use strict;
-use warnings;
-
+use Moose;
+use namespace::clean -except => 'meta';
 use MRO::Compat;
 use Tie::RefHash;
-use Class::Inspector;
 use Catalyst::Authentication::Realm;
 
-our $VERSION = "0.10015";
+with 'MooseX::Emulate::Class::Accessor::Fast';
+
+__PACKAGE__->mk_accessors(qw/_user/);
+
+our $VERSION = "0.10023";
 
 sub set_authenticated {
     my ( $c, $user, $realmname ) = @_;
@@ -474,6 +472,7 @@ sub auth_stores {
     my %hash = ( 'default' => $self->get_auth_realm('default')->store);
 }
 
+__PACKAGE__->meta->make_immutable;
 __PACKAGE__;
 
 __END__
@@ -482,8 +481,7 @@ __END__
 
 =head1 NAME
 
-Catalyst::Plugin::Authentication - Infrastructure plugin for the Catalyst
-authentication framework.
+Catalyst::Plugin::Authentication - Infrastructure plugin for the Catalyst authentication framework.
 
 =head1 SYNOPSIS
 
@@ -863,14 +861,20 @@ default realm is checked.
 =head2 $c->user( )
 
 Returns the currently logged in user, or undef if there is none.
+Normally the user is re-retrieved from the store.
+For L<Catalyst::Authentication::Store::DBIx::Class> the user is re-restored
+using the primary key of the user table.
+Thus B<user> can throw an error even though B<user_exists>
+returned true.
 
 =head2 $c->user_exists( )
 
 Returns true if a user is logged in right now. The difference between
-user_exists and user is that user_exists will return true if a user is logged
+B<user_exists> and B<user> is that user_exists will return true if a user is logged
 in, even if it has not been yet retrieved from the storage backend. If you only
 need to know if the user is logged in, depending on the storage mechanism this
 can be much more efficient.
+B<user_exists> only looks into the session while B<user> is trying to restore the user.
 
 =head2 $c->user_in_realm( $realm )
 
@@ -887,6 +891,9 @@ and the session.  It does not delete the session.
 Fetch a particular users details, matching the provided user info, from the realm
 specified in $realm.
 
+    $user = $c->find_user({ id => $id });
+    $c->set_authenticated($user); # logs the user in and calls persist_user
+
 =head2 persist_user()
 
 Under normal circumstances the user data is only saved to the session during
@@ -911,7 +918,8 @@ for reference.
 =head2 $c->set_authenticated( $user, $realmname )
 
 Marks a user as authenticated. This is called from within the authenticate
-routine when a credential returns a user. $realmname defaults to 'default'
+routine when a credential returns a user. $realmname defaults to 'default'.
+You can use find_user to get $user
 
 =head2 $c->auth_restore_user( $user, $realmname )
 
@@ -1102,30 +1110,50 @@ Register stores into the application.
 
 =head2 $c->get_user( )
 
-=head1 AUTHORS
+=head1 SUPPORT
 
-Yuval Kogman, C<nothingmuch@woobling.org>
+Please use the rt.cpan.org bug tracker, and git patches are wecome.
 
-Jay Kuri, C<jayk@cpan.org>
+Questions on usage should be directed to the Catalyst mailing list
+or the #catalyst irc channel.
+
+=head1 AUTHORS
 
-Jess Robinson
+Yuval Kogman, C<nothingmuch@woobling.org> - original author
 
-David Kamholz
+Jay Kuri, C<jayk@cpan.org> - Large rewrite
+
+=head1 PRIMARY MAINTAINER
 
 Tomas Doran (t0m), C<bobtfish@bobtfish.net>
 
-kmx
+=head1 ADDITIONAL CONTRIBUTORS
+
+=over
+
+=item Jess Robinson
+
+=item David Kamholz
 
-Nigel Metheringham
+=item kmx
 
-Florian Ragwitz C<rafl@debian.org>
+=item Nigel Metheringham
 
-Stephan Jauernick C<stephanj@cpan.org>
+=item Florian Ragwitz C<rafl@debian.org>
+
+=item Stephan Jauernick C<stephanj@cpan.org>
+
+=item Oskari Ojala (Okko), C<perl@okko.net>
+
+=item John Napiorkowski (jnap) C<jjnapiork@cpan.org>
+
+=back
 
 =head1 COPYRIGHT & LICENSE
 
-Copyright (c) 2005 - 2009
-the Catalyst::Plugin::Authentication L</AUTHORS>
+Copyright (c) 2005 - 2012
+the Catalyst::Plugin::Authentication L</AUTHORS>,
+L</PRIMARY MAINTAINER> and L</ADDITIONAL CONTRIBUTORS>
 as listed above.
 
 This program is free software; you can redistribute