Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • AuthComponent and hashing password in cakePHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 194
    Comment on it

    Identifying and authentication of a user is very common and useful part of every web appilication, In CakePHP AuthComponent provides a way to secure user's password in encrypt manner and allow user to authenticate objects as well. It is a process of verifying a user by verifying its username and password. AuthComponent uses Hashing Password for hiding the real password to the database it can be done through blowfish, it has been added to the controller.

    AppModel:

    
    <?php 
    	App::uses('AppModel', 'Model');
    	App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
    ?>

    AppController:

    <?php
    App::uses('Controller', 'Controller');
    
    class AppController extends Controller {
    	public $components  = array('Session','Auth' => array(
                'loginRedirect' => array(
                    'controller' => 'projects',
                    'action' => 'index'
                ),
                'logoutRedirect' => array(
                    'controller' => 'projects',
                    'action' => 'index'
                ),
                'authenticate' => array(
                    'Form' => array(
                        'passwordHasher' => 'Blowfish',
                        'fields' => array('username' => 'email')
                    )
                ),
            ));
    	 public function beforeFilter() {
            parent::beforeFilter();
            $this->Auth->allow('registration','logout','getCities','getStates');	// Allow users to register and logout.
    
        }
    
    }

    Modelcontroller:

    <?php
    App::uses('Controller', 'Controller');
    App::uses('AuthComponent','Controller/Component');
    ?>

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: