Entities::User - A user entity that interacts with a web application.
used internally, see L<Entities>
A user is an entity that interacts with your webapp. Generally, this is a human person that has signed up for your service, or was created by a customer, though it could be a privileged bot or whatever.
The user is that actual entity the performs actions on your webapp, and is thus required to be authorized to perform the actions they wish to perform. This is done either by assuming <roles|Entities::Role> or by explicitely being given <actions|Entities::Action>.
NOTE: you are not meant to create user objects directly, but only through the
new_user() method in Entities.
Creates a new instance of this module. Only 'username' and 'passphrase' are required.
Returns the ID of the user, if set.
Returns a true value if the user object has an ID attribute.
Sets the ID of the user object to the provided value. Only to be used internally.
Returns the username of this user.
Changes the username of the user to the provided name.
Returns the real name of the user (i.e. person).
Changes the real name of the user to the provided name.
Returns an MD5 digest of the passphrase set for this user.
Changes the passphrase of the user to the provided passphrase. Automatically created an MD5 digest of the passphrase, so do not pass a digested string here.
In scalar context, returns an array-ref of all role names this user belongs to. In list context returns an array. If an array-ref of role names is provided, it will replace the current list.
Returns a true value if the user belongs to any role.
Returns an array of all role objects this user belongs to.
In scalar context, returns an array-ref of all action names this user has been granted. In list context returns an array. If an array-ref of action names is provided, it will replace the current list.
Returns a true value if the user has beene explicitely granted any actions.
Returns an array of all action objects this user has been granted.
Returns a true value if this user is a super-user. Super user can perform every possible action, in ANY SCOPE.
Returns the customer entity this user belongs to, if any.
Returns a true value if this user is a child of a customer entity.
In scalar context, returns an array-ref of all email addresses set for this user. In list context returns an array. If an array-ref of email addresses is provided, it will replace the current list.
Returns a true value if the user has any emails assigned.
Returns a DateTime object in the time the user object has been created.
Returns a DateTime object in the last time the object has been modified. If a DateTime object is provided, it is set as the new modified value.
Returns the Entities::Backend instance that stores this object.
Adds the user to role named
$role_name. Croaks if such a role does not exist, warns if the user is already a member of this role. Returns the user object itself.
Drops the assignment of the user to the role named
$role_name. Warns if the user doesn't belong to this role, does not croak if the role does not even exist. Returns the user object itself.
Grants the action named
$action_name to the user. Croaks if this action does not exist, warns if the user has already been granted this action. Returns the user object itself.
Returns a true value if the user has been explictely granted the action named
$action_name (i.e. not via roles).
Removes the action named
$action_name from the list of actions the user has been explictely granted to perform. This doesn't necessarily mean the user will not be able to perform this action anymore, as it might be available to them via roles. Warns if the user wasn't granted this action, does not croak if the action does not exist. Returns the user object itself.
Adds the provided email address to the user's list of email addresses. Warns if the email is already assigned to this user. Does not (yet) check if the email is not assigned to any other user. Returns the user object itself.
Returns a true value if the user has the provided email.
Removes the email address given from the user's list of email addresses. Warns if user doesn't have that address. Returns the user object itself.
The following methods are consumed by this class from the Abilities Moose role. See the documentation for that role for more information on these methods.
The following list documents any method modifications performed through the magic of Moose.
emails() methods are called with no arguments and in list context - will automatically dereference the array-ref into arrays.
Called before creating a new instance of Entities::User, this automatically turns the provided passphrase into an MD5 digest.
Automatically saves the object to the backend after any method that changed it was executed. Also updates the 'modified' attribute with the current time before saving. Note, however, that the
emails() methods are not here, since they are only meant to be used for writing internally.
<ido at ido50 dot net>
Please report any bugs or feature requests to
bug-entities at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Entities. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Copyright 2010 Ido Perlmuter.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.