NAME

Mango::Catalyst::Plugin::Authentication::User - Custom Catalyst Authentication User

SYNOPSIS

use Catalyst qw/
    -Debug
    ConfigLoader
    +Mango::Catalyst::Plugin::Authentication
    Static::Simple
/;

my $user = $c->user;
print $user->cart->count;

DESCRIPTION

Mango::Catalyst::Plugin::Authentication::User is a custom authentication user that uses Mango Catalyst models to present common user information. It is also the base class for CachedUser and AnonymousUser.

Any unknown method calls are forwarded to the internal user object, which is an instance or subclass of Mango::User.

CONSTRUCTOR

new

There should never be any reason to create one of these yourself. :-)

METHODS

cart

Returns a cart for the current user. If no cart exists, one will be created and assigned to the users current session. The same cart will be returned for a user before and after they are authenticated.

my $cart = $c->user->cart;
print $cart->count;
$cart->add(...);

Normally, a Mango::Cart is returned. If you are using a custom cart model that has set its result_class to a custom subclass of Mango::Cart, that class will be used instead.

get

Arguments: $field

Returns the specified field from the underlying user object.

$user->get('username');

#same as:
$user->username;

See Catalyst::Plugin::Authentication for the usage of this method.

get_object

Returns the underlying user object, which is a Mango::User object.

See Catalyst::Plugin::Authentication for the usage of this method.

profile

Returns a user profile for the current user. If no profile exists, one will be created and assigned to the current user.

my $profile = $c->user->profile;
print 'Welcome back ', $profile->first_name;

Normally, a Mango::Profile is returned. If you are using a custom profile model that has set its result_class to a custom subclass of Mango::Profile, that class will be used instead.

refresh

Updates the session store with the current user objects data.

roles

Returns a list containing the names of all of the roles the current user belongs to. This method is used by Catalyst::Plugin::Authorization::Roles.

The roles will be loaded form the database every time they are requested.

See Catalyst::Plugin::Authentication for the usage of this method.

supported_features

Returns an anonymous hash containing the following options:

session => 1,
roles => 1,
profiles => 1,
carts => 1

SEE ALSO

Catalyst::Plugin::Authentication, Mango::User, Mango::Profile, Mango::Cart, Mango::Catalyst::Plugin::Authentication::Store Mango::Catalyst::Plugin::Authentication::User Mango::Catalyst::Plugin::Authentication::CachedUser Mango::Catalyst::Plugin::Authentication::AnonymousUser

AUTHOR

Christopher H. Laco
CPAN ID: CLACO
claco@chrislaco.com
http://today.icantfocus.com/blog/