sub get_user {
my ( $self, $id ) = @_;
- Catalyst::Plugin::Authentication::Store::Htpasswd::User->new( $self->file->lookup_user($id) );
+ Catalyst::Plugin::Authentication::Store::Htpasswd::User->new( $self, $self->file->lookup_user($id) );
}
sub user_supports {
Catalyst::Plugin::Authentication::Store::Htpasswd::User->supports(@_);
}
+sub from_session {
+ my ( $self, $c, $id ) = @_;
+ $self->get_user( $id );
+}
+
__PACKAGE__;
__END__
use strict;
use warnings;
-BEGIN { __PACKAGE__->mk_accessors(qw/user/) }
+BEGIN { __PACKAGE__->mk_accessors(qw/user store/) }
use overload '""' => sub { shift->user->username };
sub new {
- my ( $class, $user ) = @_;
+ my ( $class, $store, $user ) = @_;
- bless { user => $user }, $class;
+ bless { store => $store, user => $user }, $class;
}
sub supported_features {
return $self->user->username;
}
-sub from_session {
- my ($class,$c,$user) = @_;
- return $user;
+sub AUTOLOAD {
+ my $self = shift;
+
+ ( my $method ) = ( our $AUTOLOAD =~ /([^:]+)$/ );
+
+ return if $method eq "DESTROY";
+
+ $self->user->$method;
}
__PACKAGE__;
ok( $u->check_password( "s3cr3t" ), "password is s3cr3t");
+ok( $m->user_supports(qw/session/), "user_supports session");
+
+is( $u->store, $o, "can get store");
+
+can_ok( $m, "from_session" );
+can_ok( $u, "for_session" );
+
+my $recovered = $u->store->from_session( undef, $u->for_session );
+
+is( $recovered->username, $u->username, "recovery from session works");