3 package Catalyst::Plugin::Authentication::User;
9 ## chances are you want to override this.
10 sub id { shift->get('id'); }
12 ## returns the realm the user came from - not a good idea to override this.
19 ## this relies on 'supported_features' being implemented by the subclass..
20 ## but it is not an error if it is not. it just means you support nothing.
21 ## nihilist user objects are welcome here.
23 my ( $self, @spec ) = @_;
26 if ($self->can('supported_features')) {
27 $cursor = $self->supported_features;
29 # traverse the feature list,
31 #die "bad feature spec: @spec" if ref($cursor) ne "HASH";
32 return if ref($cursor) ne "HASH";
34 $cursor = $cursor->{$_};
42 ## get should return the value of the field specified as it's single argument from the underlying
43 ## user object. This is here to provide a simple, standard way of accessing individual elements of a user
44 ## object - ensuring no overlap between C::P::A::User methods and actual fieldnames.
45 ## this is not the most effecient method, since it uses introspection. If you have an underlying object
46 ## you most likely want to write this yourself.
48 my ($self, $field) = @_;
51 if ($object = $self->get_object && $object->can($field)) {
52 return $object->$field();
59 ## get_object should return the underlying user object. This is for when more advanced uses of the
60 ## user is required. Modifications to the existing user, etc. Changes in the object returned
61 ## by this routine may not be reflected in the C::P::A::User object - if this is required, re-authenticating
62 ## the user is probably the best route to take.
63 ## note that it is perfectly acceptable to return $self in cases where there is no underlying object.
68 ## this is an internal routine. I suggest you don't rely on it's presence.
69 ## sets the realm the user came from.
71 my ($self, $realmname) = @_;
72 $self->{'realm'} = $realmname;
75 ## Backwards Compatibility
76 ## you probably want auth_realm, in fact. but this does work for backwards compatibility.
79 return $self->auth_realm->{store};
90 Catalyst::Plugin::Authentication::User - Base class for user objects.
94 package MyStore::User;
95 use base qw/Catalyst::Plugin::Authentication::User/;
99 This is the base class for authenticated
107 A unique ID by which a user can be retrieved from the store.
111 Should return a class name that can be used to refetch the user using it's
116 An introspection method used to determine what features a user object has, to support credential and authorization plugins.