PHPackages                             mothership-ec/cog-user - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. mothership-ec/cog-user

AbandonedLibrary[Authentication &amp; Authorization](/categories/authentication)

mothership-ec/cog-user
======================

Cog module for a very basic and extensible user system

2.2.0(9y ago)02.6k1[14 issues](https://github.com/mothership-ec/cog-user/issues)[1 PRs](https://github.com/mothership-ec/cog-user/pulls)5proprietaryPHPPHP &gt;=5.4.0

Since Jun 6Pushed 9y ago4 watchersCompare

[ Source](https://github.com/mothership-ec/cog-user)[ Packagist](https://packagist.org/packages/mothership-ec/cog-user)[ Docs](http://mothership.ec)[ RSS](/packages/mothership-ec-cog-user/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependencies (1)Versions (27)Used By (5)

User
====

[](#user)

The `Message\User` cogule provides a simple user and permission system.

Services
--------

[](#services)

**todo: list services defined here**

Events
------

[](#events)

The following events are fired by this cogule. The event object is always an instance of `Message\User\Event\Event`.

- **user.login.attempt**: fired when a login attempt is made (only if it passes basic validation), regardless of whether or not the user exists. This event is an instance of `Message\User\Event\LoginAttemptEvent`.
- **user.login**: fired when a user successfully logs in.
- **user.logout**: fired when a user successfully logs out.
- **user.password.request**: fired when a password reset request is made, only if the user exists.
- **user.password.reset**: fired when a user successfully resets their password.
    - Note that if the password was reset via the "forgotten password" system, the user is logged in after this event is fired and the **user.login** event is then fired.
- **user.create** fired when a user is created using the `Message\User\Create` decorator.
- **user.edit** fired when a user is edited using the `Message\User\Edit` decorator.
    - Note this event is not fired when:
        - The "password request time" is updated or cleared.
        - The "last login time" is updated.
        - The user is added to or removed from a group
- **user.email\_confirmed** fired when a user confirms their email address (if required)
- **user.group.add** fired when a user is added to a group using `Message\User\Edit::addToGroup()`
- **user.group.remove** fired when a user is removed from a group using `Message\User\Edit::removeFromGroup()`

Users
-----

[](#users)

A user has the following properties:

- An ID
- An email address
- An "email confirmed" flag
- A title (e.g. Mr or Mrs)
- A forename
- A surname
- A "last login" timestamp
- A "password requested at" timestamp

And the usual metadata for creation and updating. There is no metadata for deletion because when a user is deleted they are hard deleted: they no longer exist in the database.

If your application or module needs to add more properties to a user, it is recommended to group these properties in a way that makes sense, and create a new model representing that group of properties. The `Message\User\User` object should remain a simple representation of basic user information.

For example, in an e-commerce module, address data might be stored for users. In this case, it would make sense to create a model representing a user's address, like so:

```
class UserAddress
{
	public $user;

	public $typeID;

	public $addressLines;
	public $town;
	public $postcode;
	public $countryID;
	public $stateID;
	public $telephone;
}

```

Groups
------

[](#groups)

A user group is, of course, a simple way of grouping users. The `Message\User` cogule doesn't define any groups itself, but it provides groups functionality and a framework for any other cogule to define groups.

To define a group, first you need to create a class that implements `Message\User\Group\GroupInterface`:

```
