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 8822189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:02:52+00:00 2026-06-14T06:02:52+00:00

I have a CakePHP 2.0 app that uses the AuthComponent with User model to

  • 0

I have a CakePHP 2.0 app that uses the AuthComponent with User model to successfully login to manage posts and other controllers and models. I’ll call that the “super admin” part of the site.

However, I need to create an entirely separate part of the site for advertisers. I have created model Advertiser and controller AdvertisersController. I have also created table advertisers. I am able to successfully add an advertiser user, but when I attempt to login, it fails with the invalid username or password error.

I followed suggestions in the Cookbook for Authentication and tried both of these options in the beforeFilter of my AdvertisersController:

$this->Auth->authenticate = array(
    AuthComponent::ALL => array(
        'userModel' => 'Advertiser', 
        'fields' => array('username' => 'username', 'password' => 'password'),
            'Form',
            'Basic'
    ));


$this->Auth->authenticate = array(
    'Form' => array('userModel' => 'Advertiser'),
    'Basic' => array('userModel' => 'Advertiser')
);

Any ideas? Is it not possible to use the AuthComponent with two different models/controllers?

EDIT: I updated my AdvertisersController to this:

public function beforeFilter() {

    parent::beforeFilter();

    $this->Auth->authenticate = array(
        AuthComponent::ALL => array('userModel' => 'Advertiser'),
        'Form',
        'Basic'
    );
    $this->Auth->allow('add', 'logout'); // Letting advertisers register themselves

} 

Now the login is failing altogether — no failed password error. I even tried a bogus username and password. Here is the login method in my controller:

public function login() {
        if ($this->request->is('post')) {
            if ($this->Auth->login()) {
                $this->redirect(array('controller' => 'advertisers', 'action' => 'admin'));
            } else {
                $this->Session->setFlash(__('Invalid username or password, try again'));
            }
        }
    }

I added an else print_r($this->data); exit; statement after the close of the first if and got an empty array. Couldn’t even get to the login page.

Also, the output for the form is this — POST is the method.

<form action="/advertisers/login?url=advertisers%2Flogin" id="AdvertiserLoginForm" method="post" accept-charset="utf-8">
    <div style="display:none;"><input type="hidden" name="_method" value="POST"/></div>    
    <fieldset>
        <legend>Please enter your username and password</legend>
        <div class="input text required">
            <label for="AdvertiserUsername">Username</label>
            <input name="data[Advertiser][username]" maxlength="50" type="text" id="AdvertiserUsername"/>
        </div>
        <div class="input password required">
            <label for="AdvertiserPassword">Password</label>
            <input name="data[Advertiser][password]" type="password" id="AdvertiserPassword"/>
        </div>    
    </fieldset>
    <div class="submit">
        <input  type="submit" value="Login"/>
    </div>
</form>
  • 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-14T06:02:53+00:00Added an answer on June 14, 2026 at 6:02 am

    I reposted this question with more information here. Joshua was a big help getting admin prefixing sorted out for this scenario. If it seems like “too much” for your app — see his comments here. It looks more complicated than it is, and it helps keep user controls much more defined.

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

Sidebar

Related Questions

In my CakePHP 1.2.5 app, I have a Profile model that belongsTo a User
I have a small cakePHP app that allows for user's to login and be
I have built a cakephp app that needs the user to login or register(for
I have a rather simple CakePHP app that uses the Auth component to restrict
I have two models in my CakePHP app: Company and User . They are
I have a cakephp app that when I logout it add's admin/login ti the
I have a CakePHP app that is being moved to Sql Server from MySql.
I have a simple cakephp app with table articles that has a cat_id column
Please have a look at this validation array in my cakephp app for model
I have a backend data management console written with CakePHP that allows a user

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.