Question

I'm using a login with a scope to ensure that the user account is active. If the login fails how can i tell if it failed because the email was not matched or if the accounts wasn't activated?

Also, i didn't understand all of the documentation in the cakephp cookbooks, could you please look at my auth section in my components array?
The Email field in the html table and sql table are called 'AccountEmail'
The Password field in the html table and sql table are called 'AccountPassword'
The row in the sql table for active accounts is called 'AccountActive' and is an int type with a value of 0 if the user is not active and 1 if it is active.

'Auth' => array(
        'logoutRedirect' => array('controller' => 'Accounts', 'action' => 'login'),
        'authError' => 'You can\'t Access That Page',
        'authorize' => array('Controller'),
        'fields' => array('AccountEmail' => 'AccountEmail', 'AccountPassword' => 'AccountPassword'),
        'scope' => array('AccountActive' => '1')
    )
Was it helpful?

Solution

You're missing which authentication handler to use and your fields configuration was wrong.

I'll assume you want to use a form to login:

/**
 * Auth component configuration
 */
public $components = array(
  'Auth'=> array(
    'logoutRedirect' => array(
      'controller' => 'Accounts', 
      'action' => 'login'
    ),
    'authError' => 'You can\'t Access That Page',
    'authorize' => array('Controller'),
    'authenticate' => array(
      'Form' => array(
        'fields' => array(
          'username' => 'AccountEmail',
          'password' => 'AccountPassword'
        ),
        'scope' => array('AccountActive' => '1')
      )
    )
  )
);  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top