1 package Catalyst::Plugin::Authentication::User;
5 use base qw/Class::Accessor::Fast/;
7 ## auth_realm is the realm this user came from.
9 __PACKAGE__->mk_accessors(qw/auth_realm store/);
12 ## THIS IS NOT A COMPLETE CLASS! it is intended to provide base functionality only.
13 ## translation - it won't work if you try to use it directly.
15 ## chances are you want to override this.
16 sub id { shift->get('id'); }
18 ## this relies on 'supported_features' being implemented by the subclass..
19 ## but it is not an error if it is not. it just means you support nothing.
20 ## nihilist user objects are welcome here.
22 my ( $self, @spec ) = @_;
25 if ($self->can('supported_features')) {
26 $cursor = $self->supported_features;
28 # traverse the feature list,
30 #die "bad feature spec: @spec" if ref($cursor) ne "HASH";
31 return if ref($cursor) ne "HASH";
33 $cursor = $cursor->{$_};
41 ## get should return the value of the field specified as it's single argument from the underlying
42 ## user object. This is here to provide a simple, standard way of accessing individual elements of a user
43 ## object - ensuring no overlap between C::P::A::User methods and actual fieldnames.
44 ## this is not the most effecient method, since it uses introspection. If you have an underlying object
45 ## you most likely want to write this yourself.
47 my ($self, $field) = @_;
50 if ($object = $self->get_object and $object->can($field)) {
51 return $object->$field();
58 ## get_object should return the underlying user object. This is for when more advanced uses of the
59 ## user is required. Modifications to the existing user, etc. Changes in the object returned
60 ## by this routine may not be reflected in the C::P::A::User object - if this is required, re-authenticating
61 ## the user is probably the best route to take.
62 ## note that it is perfectly acceptable to return $self in cases where there is no underlying object.
67 ## Backwards Compatibility
68 ## you probably want auth_realm, in fact. but this does work for backwards compatibility.
69 ## store should be a read-write accessor - so it was moved to mk_accessors
72 ## return $self->auth_realm->{store};
83 Catalyst::Plugin::Authentication::User - Base class for user objects.
87 package MyStore::User;
88 use base qw/Catalyst::Plugin::Authentication::User/;
92 This is the base class for authenticated
100 A unique ID by which a user can be retrieved from the store.
104 Should return a class name that can be used to refetch the user using it's
109 An introspection method used to determine what features a user object has, to support credential and authorization plugins.