implement id() in Auth::Store::Htpasswd and change other methods to use it
David Kamholz [Sun, 27 Nov 2005 12:12:31 +0000 (12:12 +0000)]
lib/Catalyst/Plugin/Authentication/Store/Htpasswd/User.pm

index ce4388a..f018026 100644 (file)
@@ -8,7 +8,7 @@ use warnings;
 
 BEGIN { __PACKAGE__->mk_accessors(qw/user store/) }
 
-use overload '""' => sub { shift->user->username };
+use overload '""' => sub { shift->id }, fallback => 1;
 
 sub new {
        my ( $class, $store, $user ) = @_;
@@ -16,6 +16,11 @@ sub new {
        bless { store => $store, user => $user }, $class;
 }
 
+sub id {
+    my $self = shift;
+    return $self->user->username;
+}
+
 sub supported_features {
        return {
                password => {
@@ -27,18 +32,17 @@ sub supported_features {
 
 sub check_password {
        my ( $self, $password ) = @_;
-
        return $self->user->check_password( $password );
 }
 
 sub roles {
        my $self = shift;
-       split( ",", $self->user->extra_info );
+       split( /,/, $self->user->extra_info );
 }
 
 sub for_session {
     my $self = shift;
-    return $self->user->username;
+    return $self->id;
 }
 
 sub AUTOLOAD {