Browsing through GitHub and I found a pretty powerful CakePHP plugin called CakeDC Users that has a lot of features (Account verification, password reset, etc) for a creating a login/authentication system. I like it because it seems to be written by some of the actual CakePHP developers and it gets updated a lot but there seems to be absolutely zero documentation anywhere on it. I've just come across this plugin recently, since I was trying to see if there's a better way than "rolling" with my own solution. So I was wondering if anybody here has had experience with it and if so could point to some decent documentation online.
Edit There is some stuff at the bottom of the readme, but it hasn't been too intuitive for me.
Alternate question, if you don't use this plugin, is there a login/authentication plugin you use in CakePHP that you use for login/authentication?
I have ran into the same problem with using the CakeDC plugins, a lot of them have little/no documentation.
However, there is not "Zero" documentation for it, you can see how to set it up for the most part at the bottom of the github page in the read me. Also you need to put this inside your AppController::beforeFilter() method.
$this->Auth->authorize = 'controller';
$this->Auth->fields = array('username' => 'email', 'password' => 'passwd');
$this->Auth->loginAction = array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'admin' => false);
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->authError = __('Sorry, but you need to login to access this location.', true);
$this->Auth->loginError = __('Invalid e-mail / password
combination. Please try again', true);
$this->Auth->autoRedirect = true;
$this->Auth->userModel = 'User';
$this->Auth->userScope = array('User.active' => 1);
if ($this->Auth->user()) {
$this->set('userData', $this->Auth->user());
$this->set('isAuthorized', ($this->Auth->user('id') != ''));
}
Also, you need an isAuthorized()
function, something as simple as this will do:
public function isAuthorized() {
return true;
}
Additionally, you will need to allow the 'login' action (this will involve editing the plugin files). Just add 'login' to the $this->Auth->allow()
in users_controller.php
.
This question is pretty old now, but as it's not marked as resolved and we've been doing a lot on the documentation since then I think it's worth to update:
Documentation can be found here:
For the version 3+ of the framework
- https://github.com/CakeDC/users/blob/master/Docs/Home.md
- Tutorial > http://www.cakedc.com/jorge_gonzalez/2016/02/21/cakedc_users_plugin_for_cakephp_3_-_update
- CakePHP Facebook login tutorial >
http://www.cakedc.com/jorge_gonzalez/2016/02/21/cakephp_facebook_login_using_cakedc_users_plugin_-_update_3_1_5
For the (old) version 2
- https://github.com/CakeDC/users/blob/2.x/Docs/Home.md
After exhaustive search I found a tutorial on how to use CakeDC!
Here it is