Myco::Core::User - Interface to Myco User Objects
1.0
use Myco::Core::User; # Constructors. my $user = Myco::Core::User->new; # See Myco::Entity for more. # Class Methods. # Instance Methods. my $person = $user->get_person; $user->set_person($person); my $login = $user->login; $login->set_login($login); $user->set_pass($pass); if ($user->chk_pass($pass)) { # Allow access. } $user->save; $user->destroy;
This Class provides the basic interface to all Myco user objects. It offers the ability to set and get the login name, and to set and check the password. The password is double-MD5 hash encrypted for security.
Myco::Query::Meta::Query objects defining generic and reusable queries for finding Myco::Core::User objects.
my $metadata = Myco::Core::User->introspect->get_queries; my $default_query = $metadata->{default}; my @results = $default_query->run_query(login => 'doej');
Find a user object with a given unique login attribute.
my $metadata = Myco::Core::User->introspect->get_queries; my $default_query = $metadata->{by_person}; my @results = $default_query->run_query(person => $p);
Find a user object with a person attribute set to a given Myco::Core::Person object, $p.
Constructor, accessors, and other methods -- as inherited from Myco::Entity.
Attributes may be initially set during object construction (with new()) but otherwise are accessed solely through accessor methods. Typical usage:
new()
Set attribute value
$user->set_attribute($value);
Check functions (see Class::Tangram) perform data validation. If there is any concern that the set method might be called with invalid data then the call should be wrapped in an eval block to catch exceptions that would result.
eval
Get attribute value
$value = $user->get_attribute;
Available attributes are listed below, using syntax borrowed from UML class diagrams; for each showing the name, type, default initial value (if any), and, following that, a description.
The person object to which this user belongs. Access this object to output name information about a user.
The user's login name.
The user's login password. Internally, it will be encrypted in a double-MD5 hash before being stored in the system.
The user's roles. These are stored in a hash, where the keys are the role names and the values are an integer, usually "1". Mostly, you shouldn't use the hash to get at the roles, though. See below for the methods specific to Role access.
############################################################################## # Methods ##############################################################################
if ($user->chk_pass($pass)) { # Allow access. }
Checks the user's pass word or phrase. Returns true if the pass word or phrase is correct, and false if it is not.
my @roles = $user->get_roles; my $roles_aref = $user->get_roles;
Returns a list (in an array context) or an anonymous array (in a scalar context) of all the roles assigned to the user.
$user->add_roles(@roles);
Adds the listed roles to the user. If any role in @roles does not actually exist as a role, then add_roles() will throw an exception.
add_roles()
$user->del_roles(@roles);
Deletes the listed roles from the user.
$user->get_roles_hash;
Returns an anonymous hash of all of the roles assigned to the user. The hash keys are the role names, and the values are a simple integer (usually one). This is the internal representation of the roles in the User object, and normally this method will only be used internally.
$user->get_displayname;
Returns the displayname of the person (first and last name) associated with a user.
my $u = Myco::Core::User->find_user($person);
Finds a user, given a Myco::Core::Person. This is a simple wrapper around the 'by_person' query contained in the Myco::Core::User query.
Copyright (c) 2006 the myco project. All rights reserved. This software is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Charles Owens <charles@mycohq.com>, David Wheeler <david@wheeler.net>, and Ben Sommer <ben@mycohq.com>
Myco, Myco::Entity, Myco::Core::Person, Tangram, Class::Tangram,
To install Myco::Core::User, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Myco::Core::User
CPAN shell
perl -MCPAN -e shell install Myco::Core::User
For more information on module installation, please visit the detailed CPAN module installation guide.