2017 © Pedro Peláez
 

cakephp-plugin cakephp-users

Users plugin for CakePHP

image

cakemanager/cakephp-users

Users plugin for CakePHP

  • Monday, September 19, 2016
  • by bobmulder
  • Repository
  • 6 Watchers
  • 6 Stars
  • 237 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 8 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Users plugin for CakePHP

Note: This is a non-stable plugin for CakePHP 3.x at this time. It is currently under development and should be considered experimental., (*1)

Table of Contents

Features

  • CakeAdmin compatible
  • Forgot Password functionality
  • Role-management (Set up your own roles)
  • E-mail integration
  • Easy to install

Installation

You can install this plugin into your CakePHP application using composer., (*2)

The recommended way to install composer packages is:, (*3)

composer require cakemanager/cakephp-users

Now load the plugin with the command:, (*4)

$ bin/cake plugin load -r -b Users

Run the database migrations with:, (*5)

$ bin/cake migrations migrate --plugin Users

Usage

Using the users-plugin is very easy. Use the following code in your AppController:, (*6)

public function initialize()
{
    parent::initialize();
    $this->loadComponent('Users.UserManager');
}

You can change configurations of the AuthComponent with $this->Users->config('auth.*settings*); or $this->Auth->config() (after loading the UserManagement component)., (*7)

From now on you will be able to register and login. Use the CakeAdmin Plugin to manage your roles and users easily., (*8)

Configurations

The following configurations are available. All configurations can be set via Configure::write() in your config/bootstrap.php file., (*9)

Users.fields

By default you will register and login with email and password. When you want to use your own fields, like username and passwrd you can use the following:, (*10)

Configure::write('Users.fields', [
    'username' => 'username',
    'password' => 'passwrd'
]);

Users.email

There are some configurations for email: - Users.email.from - Array to define the sender. Default ['admin@cakemanager.org' => 'Bob | CakeManager']. - Users.email.transport - The transport to use. Default set to default. - Users.email.afterRegister.subject - The subject of the email sent when an user has been registered. - Users.email.afterForgot.subject - The subject of the email sent when an user forgot his password., (*11)

Users.defaultController

The plugin has a default controller which contains all default user-related actions (login, logout, reset, forgot). There may be times that you want to use your own controller. You can disable the default built-in controller by setting Users.defaultController to false:, (*12)

Configure::write('Users.defaultController', false);

When you do this, the routes for the plugin are not set, and trying to reach te controller will fail because you will be redirected to the previous location., (*13)

Note: This feature can be helpfull by using the user-management only for your API., (*14)

UserManager Component

The UserManager Component default handles the Auth for your app. However, this component is also helpful to add user- related actions to your system! By calling the login-function ($this->UserManager->login()) you are using the login-action. The same is for:, (*15)

  • login() - Logs the user in.
  • logout() - Logs the user off.
  • activate($email, $requestKey) - Activates the user. Don't forget to pass the variables.
  • forgot - User leaves his e-mailaddress to receive an e-mail to set a new password.
  • reset($email, $requestKey) - Creates a new password for the user. Don't forget to pass the variables.

This methods can be helpful when you want to customize your user-related actions., (*16)

Note: Don't forget to set the Users.defaultController configuration to false, mentioned above!, (*17)

CakeAdmin

The plugin is CakeAdmin compatible! This means that the Users and Roles can be managed in the Admin panel of the CakeAdmin plugin., (*18)

Keep in touch

If you need some help or got ideas for this plugin, feel free to chat at Gitter., (*19)

Pull Requests are always more than welcome!, (*20)

The Versions

19/09 2016

dev-master

9999999-dev

Users plugin for CakePHP

  Sources   Download

The Requires

 

The Development Requires