josegonzalez / cakephp-users
Users plugin for CakePHP
Installs: 59
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:cakephp-plugin
Requires
- php: >=5.6
- admad/cakephp-social-auth: 0.6.*
- cakephp/cakephp: >=3.5.0 <4.0.0
- friendsofcake/crud: 5.*
- friendsofcake/crud-users: 0.*
- josegonzalez/cakephp-upload: 4.*
- muffin/tokenize: 1.1.*
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-29 05:08:12 UTC
README
Provides user authentication and administration for your CRUD-enabled application.
Installation
You can install this plugin into your CakePHP application using composer.
The recommended way to install composer packages is:
composer require josegonzalez/cakephp-users
Usage
Load the plugin
Plugin::load('Users', ['bootstrap' => true, 'routes' => true]);
Create the users
table with a migration similar to the following:
bin/cake bake migration create_users verified:boolean active:boolean email:string:unique:U_email password avatar avatar_dir created modified
If enabling password resets, you will also need to load the Muffin/Tokenize
plugin and run it's migrations:
bin/cake plugin load Muffin/Tokenize --routes bin/cake migrations migrate --plugin Muffin/Tokenize
If enablign social authenticationn, you will also need to load the ADmad/SocialAuth
pluginn and run it's migrations:
bin/cake plugin load ADmad/SocialAuth -b -r bin/cake migrations migrate -p ADmad/SocialAuth
And add the AuthTrait
to your AppController
:
namespace App\Controller; use Cake\Controller\Controller; use Users\Controller\AuthTrait; class AppController extends Controller { use AuthTrait; public function initialize() { $this->loadAuthComponent(); } }
Configuration
return [ 'Users' => [ // Name of the table to use 'userModel' => 'Users.Users', // Enable users the ability to upload avatars 'enableAvatarUploads' => true, // Enable the password-reset flow 'enablePasswordReset' => true, // Require that a user's email be authenticated 'requireEmailAuthentication' => true, // Make all users active immediately 'setActiveOnCreation' => true, // Fields to use for authentication 'fields' => [ 'username' => 'email', 'password' => 'password', ], // SocialAuth plugin configuration 'social' => [ 'getUserCallback' => 'getUserFromSocialProfile', 'serviceConfig' => [ 'provider' => [ 'facebook' => [ 'applicationId' => '<application id>', 'applicationSecret' => '<application secret>', 'scope' => [ 'email' ] ], ], ], ], ], ];