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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:17:55+00:00 2026-06-04T16:17:55+00:00

I am unable to wrap my head around how the Auth component works in

  • 0

I am unable to wrap my head around how the Auth component works in cakePHP. I am using 2.1

My login works perfectly, and from my understanding I can set the default component in the appController, which I did as listed below.

 // App controller:

 public $components = array(
    'Session',

    'Auth' => array(
        'loginAction' => array(
            'controller' => 'users',
            'action' => 'login',
        ),
        'authError' => "Your username and password is incorrect, please try again.",
        'authenticate' => array(
            'Form' => array(
                'scope' => array('User.user_status_id' => 1)
            )
        ),
        'redirect' => array("controller" => "users", "action" => "profile"),
        'loginRedirect' => array("controller" => "users", "action" => "profile")
    )
);

public function beforeFilter() {
    $this->Auth->allow("home");
   if($this->Auth->loggedIn() == true) {
       $this->set("user_name",$this->Auth->user("first_name")." ".$this->Auth->user("last_name"));
       $this->set("loggedIn",true);
       if($this->Auth->user("user_type_id") == 5) {
           $this->set("navigation","navigation_admin");
       } else {
           $this->set("navigation","navigation_loggedin");
       }
   } else {
       $this->set("loggedIn",false);
       $this->set("navigation","navigation_notloggedin");
   }

}

home is located /app/view/home.ctp, however, I cannot access the page without being logged in. Next I have 2 different user levels, normal and administrator. I want to limit certain actions in controllers based if you’re an admin or not.

In my UserController I have example:

 public function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->allow("login");
    if($this->Auth->user("user_type_id") != 5) {
        $this->Auth->allow("login","profile");
    }
}

But irrespective of the user type, everyone can view the actions.

In my pages controller I also have the following:

 public function beforeFilter() {
        parent::beforeFilter();
        $this->Auth->allow("*");
    }

But I have to be logged in to view any pages.

I am convinced I am doing something wrong, but I cannot wrap my head around what, any help?

  • 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-04T16:17:57+00:00Added an answer on June 4, 2026 at 4:17 pm

    First, home is not an action on the controller, so $this->Auth->allow("home"); wouldn’t have an effect. $this->Auth->allow("display"); would but would allow all pages to be seen (not sure if that’s intended).

    Secondly, you are using $this->Auth->allow("*"); after you call the parent’s beforeFilter, which means that AppController::beforeFilter() would treat it as if the user wasn’t logged in, since it doesn’t know what you’ve allowed after the fact.

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

Sidebar

Related Questions

I am trying to wrap my head around the feasability of parsing a log
I have been trying to wrap my head around this for a while now
I'm trying to wrap my head around Linq to XML. I have an XML
I searched old questions, but couldn't find an answer or wrap my head around
I simply cannot wrap my head around how to solve this problem and after
I've been trying to wrap my head around this the whole day... Basically, I
Error: Unable to read data from the transport connection: A blocking operation was interrupted
I'm unable to execute the following prepared statement , PREPARE stmt FROM 'SELECT sb.id,sb.category,sb.make,sb.name,sb.pic,rs.slot
I'm getting an Unable to obtain public key for StrongNameKeyPair. exception using Newtonsoft's JsonConvert.SerializeObject
I want to turn these three methods into one, but am unable to wrap

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.