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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:50:10+00:00 2026-05-23T19:50:10+00:00

I have a CakePHP 1.3 application that has a login system, which works well.

  • 0

I have a CakePHP 1.3 application that has a login system, which works well. It uses a DB with a users table, which existed before creating this app.

I’m using Auth in my AppController. The login function looks like

function login() {}

and it’s located in the users_controller.

Everything works fine, as I said, but I have problems trying to add a new functionality. I would like to, during the login process, detect if a user has introduced a specific combination of login/password (let’s say admin/adminpwd). If so, the login should be succesful AND he would be taken to an admin area (/admin/index). Otherwise, the login process should work as usual.

Once in this admin area (controlled by an admin_controller), this user should be able to perform some actions exclusive to him, no to the rest of users (even if they type on the browser /admin/action).

I’ve read about ACL, and probably it would help with this, but it seems too complicated for what I really need. Is there any simple way to do this? I guess I should modify the login function, but I don’t really know how exactly, and if there’s anything else I should change… any ideas?

  • 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-05-23T19:50:10+00:00Added an answer on May 23, 2026 at 7:50 pm

    Let’s just see some code…

    class UsersController extends AppController {
    
        // we're moving the variable to AppController!
    
        public function login() {
    
            $usrInfo = $this->Auth->user();
    
            if (isset($usrInfo) {
    
                // this index name might not be right.  I'm going off memory please check this!
                if (in_array($usrInfo['username'], $this->adminUsers)) {
                    // do your code here for admin users.  
                    // could be a redirect or just changing the layout used
                } else {
                    // is a user that is logged in but not in our admin list
                }
    
        }
    
    }
    

    To test if the user is logged in you would need to do something like the following:

    class AppController extends Controller {
    
        protected $adminUsers = array('joe_blow_uname', 'jane_blow_uname');
    
        public function beforeFilter() {
    
            $routing = Configure::read('Routing.admin');
            $usrInfo = $this->Auth->user();
    
            if (isset($this->params[$routing]) && isset($usrInfo)) {
                if (!in_array($usrInfo['username'], $this->adminUsers)) {
                    // do code here for non-admin users using /admin prefix
                }
            }
    
        }
    
    }
    

    Let me know if this doesn’t help.

    Or worse breaks something…

    Edit:

    This is really not the best way to do this obviously. ACL or setting up some kind of group in your database would probably be better. BUT, it is a relatively quick-n-dirty way that, for a small site, should work fine.

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

Sidebar

Related Questions

I have a CakePHP application that uses a number of vendor classes, including one
I'm developing a CakePHP 1.3 application which needs to login users backend and frontend.
I've got a model in CakePHP that doesn't have a table, called Upload. I've
I have an existing web application that I am converting to use CakePHP. The
I have an application in CakePHP that lists businesses. I have a business model/controller,
I have integrated galeria to show images in my cakephp application.It works fine.But after
I have a CakePHP 1.2 application. I'm running into the case where I need
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
I have a CakePHP application where I am trying to get a count of
I am working on development of an application using CakePHP framework. We all have

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.