CakeDC User Plugin - Is there Documentation Anywhe

2019-02-17 08:35发布

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?

3条回答
We Are One
2楼-- · 2019-02-17 09:15

After exhaustive search I found a tutorial on how to use CakeDC!

Here it is

查看更多
手持菜刀,她持情操
3楼-- · 2019-02-17 09:16

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

For the (old) version 2

查看更多
The star\"
4楼-- · 2019-02-17 09:24

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.

查看更多
登录 后发表回答