Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7815511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:32:42+00:00 2026-06-02T05:32:42+00:00

In my view I have: <?php echo $this->Form->create(‘User’, array(controller => Users, action => login,

  • 0

In my view I have:

<?php
echo $this->Form->create('User', array("controller" => "Users", "action" => "login", "method" => "post"));
echo $this->Form->input('User.email', array("label" => false));
echo $this->Form->input('User.password', array("label" => false, 'class' => 'password-input'));
echo $this->Form->end(); ?>

In my AppController:

public $components = array(
        'Session',
        'Auth'
    );

    function beforeFilter(){
        $this->Auth->fields = array(
            'username' => 'email',
            'password' => 'password'
        );
    }

In my UsersController:

function beforeFilter(){
        $this->Auth->allow('sign_up', 'login', 'logout', 'forgot_password');
        return parent::beforeFilter();
    }
public function login() {
        if ($this->Auth->login()) {
            $this->Session->setFlash(__('Successfully logged in'), 'default', array('class' => 'success'));
            $this->redirect($this->Auth->redirect());
        } else {
            if (!empty($this->request->data)) {
                $this->Session->setFlash(__('Username or password is incorrect'), 'default', array('class' => 'notice'));
            }
        }
    }

But the login is not working, what am I missing?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:32:44+00:00Added an answer on June 2, 2026 at 5:32 am

    I believe the problem is:

    function beforeFilter(){
        $this->Auth->fields = array(
            'username' => 'email',
            'password' => 'password'
        );
    }
    

    That was how custom login fields were specified in CakePHP 1.3. CakePHP 2.0 instead requires you to specify these fields in the public $components = array(...);. The 1.3 API shows that Auth has a $fields property, but the 2.0 API shows that there is no longer a $fields property. So you must:

    public $components = array(
        'Session',
        'Auth' => array(
            'authenticate' => array(
                'Form' => array(
                    'fields' => array('username' => 'email')
                )
            )
        )
    );
    

    More information can be found at: http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#configuring-authentication-handlers

    Please tell me how it works out!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code for my login view: <?php echo $session->flash('auth'); echo $this->Form->create('User',
Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?>
how to create a widget out of an existing login action view ? this
First of all I have a Model user.php which connects to users table. I
I have a User controller and User model. This model and associated database table
I have a form for user to input some feedbacks, and this form has
We have FireSymfony that allows one to view the Symfony, PHP variables in a
I have a file called 34.php?session=2534464a39a2c97cb7113689726a4e52 in my /var/www/html folder but I can't view
I have this code to display the data retrieved from DB in accounts_view.php :
i have view like 'home/details/5', it can be access by anonymous user. but there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.