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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:38:04+00:00 2026-05-22T14:38:04+00:00

I have an application that requires authentication, and have a User model. There are

  • 0

I have an application that requires authentication, and have a User model. There are 4 levels of authorisation with the following rules:

  1. Level 1 users can create/edit/delete all level 2,3 and 4 users.
  2. Level 2 users can create level 3 and 4 users, and edit only those users they own.
  3. Levels 3 and 4 have no authorisation to create/edit/delete users.
  4. UPDATE: Level 3 and 4 users could have multiple level 2 parent users.

In addition to this, I want all users to be able to login through a single interface.

Are there any patterns for dealing with such a hierarchy? using an authorisation plugin such as cancan will allow me to define the different levels of authorisation, but not the relationships between the different users.

Essentially I would like a design that would enable me to write controller code such as this:

@level_two_users = current_user.find_all_my_level_two_users

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-05-22T14:38:05+00:00Added an answer on May 22, 2026 at 2:38 pm

    You could add a attribute level to your user model and a method to query for allowed users.

    To get all users with level X just use a query like User.find_all_by_level(2)

    class User
      attr_accessible :level
    
      def allowed_to_edit_user?(user)
        case self[:level]
          when 1
            user.level > 1
          when 2
            user.level > 2 && user.created_by?(self)
        end
        false
      end
    
      def allowed_to_create_user_with_level?(level)
        self[:level] <= 2 && self[:level] < level 
      end
    end
    

    Btw. who creates level 1 users? 😉

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

Sidebar

Related Questions

I have a site that requires Windows Authentication the application obtains the credential from
I have an application that requires the user to reenter their password between 15
I have a script that calls an application that requires user input, e.g. run
I am working on an application that requires user authentication to access a profile.
I'm writing a c# application that requires user authentication. When the user hits the
I have a CherryPy application that is stateless but requires authentication. Rather than implementing
I'm writing a jQuery Mobile application that requires user authentication. The same user cannot
I have VB application that requires visual service pack 6 to run , now
I have an application that requires .Net. I have found out how to check
I have an application that requires resizing of a component that will be scaled

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.