Home » Interview Question » Cake Php » Using another field instead of username in CakePHP AuthComponent

Using another field instead of username in CakePHP AuthComponent

Using another field instead of username in CakePHP AuthComponent

Authentication is the process of identify the users by provided credentials and ensuring that users are who which have the access permission. By default in cakephp this is done through a username and password that are checked against a known list of users, but if we want to authenticate other field((emailid) in place of username then we configure it in authComponents When you are using authComponents in cakephp to authenticate the user, first of all to initialize the authComponents in your controller or app controller (useable for all controller).

You can define Auth Component in AppController as below /app/Controller/AppController.php

Define custom fields in your controller, other than username and password. By default in cakephp authentication is done through a username and password that are checked against a known list of users, but if we want to authenticate another field id in place of username then we configure it in components in your controller. Define $components array in your controller and also define field in place of username and password

, , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">