CakeDC Users plugin: Use email field as a username -
is possible configure cakedc's users plugin use email field username?
by default there both username , email fields in users plugin , work great! use email username authentication, user registration can simplified.
i have tried overriding usersauthcomponent loading auth component in appcontroller, login stops working , says "wrong username or password".
public function initialize() { parent::initialize(); $this->loadcomponent('flash'); $this->loadcomponent('auth', [ 'loginaction' => [ 'plugin' => 'cakedc/users', 'controller' => 'users', 'action' => 'login', ], 'authenticate' => [ 'all' => [ 'scope' => ['active' => 1] ], 'cakedc/users.rememberme', 'form' => [ 'fields' => ['username' => 'email', 'password' => 'password'] ] ], 'authorize' => [ 'cakedc/users.superuser', 'cakedc/users.simplerbac', ], 'storage' => 'session' ]); $this->loadcomponent('cakedc/users.usersauth'); }
following documentation, turned off usersauthcomponent in bootstrap.php.
configure::write('users.auth', false);
is there trick? believe possible, or maybe bug?
i using cakephp 3.1 , cakedc user plugin 3.1
i think multicolumnauthenticate used for, viewing plugin on github. try this:
public function initialize() { parent::initialize(); $this->loadcomponent('flash'); $this->loadcomponent('auth', [ 'loginaction' => [ 'plugin' => 'cakedc/users', 'controller' => 'users', 'action' => 'login', ], 'authenticate' => [ 'all' => [ 'scope' => ['active' => 1] ], 'cakedc/users.rememberme', 'foc/authenticate.multicolumn' => [ 'fields' => [ 'username' => 'username', 'password' => 'password' ], 'columns' => ['username', 'email'], 'usermodel' => 'users', ] ], 'authorize' => [ 'cakedc/users.superuser', 'cakedc/users.simplerbac', ], 'storage' => 'session' ]); $this->loadcomponent('cakedc/users.usersauth'); }
this check against both email , username when logging in.
Comments
Post a Comment