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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:20:18+00:00 2026-05-24T02:20:18+00:00

At the moment I use Auth Component for users to login / logout –

  • 0

At the moment I use Auth Component for users to login / logout – ACL is defined to sort between user groups (Guests, Users, Admins) – with obvious restrictions; Admin being able to access everything, the user can only access edit in the users controller and the guest being able to see just the display / index / view etc etc.

Now to prevent users from editing another user – I have a function called isOwner() which essentially checks if you are trying to edit your own profile; and also checks if it is an admin trying to edit. If the user is the owner of the content they’re trying to edit, then it allows it otherwise it just redirects with a flash message.

Having read through http://book.cakephp.org/view/1245/Defining-Permissions-Cake-s-Database-ACL – I wondered if it was possible to define this in the ACL?

Something along the lines of:

$this->Acl->allow(array('model' => 'User', 'foreign_key' => $id), 'Users', 'edit', $id) 

Though I haven’t dug deep enough and I’m assuming I’d have to make some sort of beforeSave() with the above line for each new user registered to be allowed to edit his profile.

  • 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-24T02:20:18+00:00Added an answer on May 24, 2026 at 2:20 am

    [ i’ve decided to post this as an answer cause it contains code examples ]

    You could create a component (or a function) and use the beforeFilter() callback in the app_controller, that way you wont need to manually add the function to all controllers.

    Also you could use multiple prefixes for the actions (see Routing.prefixes in the core), it will make it easier to control the access. Something like:

    [app_controller.php]

    function beforeFilter() {
        if(isset($this->params['prefix']) && $this->params['prefix'] == 'admin'){
             if(!isAdmin() || !isOwner())
                 $this->cakeError('error404');
        }
    }
    

    [users_controller.php]

      function admin_edit($id = null){
            ... // edit as usual
        }
    

    In a LAMP stack your bottleneck is usually at the database

    my problem with cake is the number of queries it makes. Once i saw that my “contact” page that made 21 queries only to retrieve the data structure, and the permissions for this public page.

    The only way to justify the use of ACL for accessing data is when the permissions are dynamic, i.e. “user#29 can edit user#12 because the Admin decided it in the backoffice“. But if you have static rules for accessing the data (like “users can only edit their own info and admins can edit everything“) its kinda useless to perform queries when you already know the answers, because this rules won’t change in time.

    so it all depends on your app.. Finally, one last thought, if you’re still planing to make more queries =P you could set the authorize method of the Auth component. But using the ACL Component for this, seems to me like a bad idea

    Cheers!

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

Sidebar

Related Questions

At the moment we use HSQLDB as an embedded database, but we search for
At the moment I use PHP for almost everything I develop for the Web
This question is for C# 2.0 Winform. For the moment I use checkboxes to
I use a stream reader to import some data and at the moment I
I need to use sendmail from Macs in an office. At the moment, I
At the moment, our application uses the Trident Win32 component, but we want to
Django's auth messages look pretty handy for notifying a CMS user of some configuration
At the moment I have a Ruby on Rails application which maintains my Users,
I'm on an optimization kick, at the moment. I tend to use multiple tables,
At the moment my code (PHP) has too many SQL queries in it. eg...

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.