-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature discussion] Roles (partly done by the way, see admin feature) #603
Comments
Definitly a good feature! Let's put this on the (non-existing yet) ToDo-list for 3.1. |
I personally created some entries in the config-array with the id's of each role, so I can check it like this:
But this is only good if you only got a few roles of course. |
That's fine for small stuff i guess, however it doesn't really allow you to add/change or delete any roles without going in to the code, i feel like doing it this way would be a mistake. |
Yes you're right, but the last part of your answer is the same with your code i guess. |
That's true, regardless of how you do it it's going to require editing the code unless you sort of, hmm i guess if you had a record of each controller / view in the database with the roles that are allowed to use/view then the only time you would need to manually change the roles would be when inserting it in to the database, not sure i have made this very clear, this solution would prehaps be to bloated anyhow |
@ALL: I think it's a good idea to completely rebuild the AccountTypeModel stuff to RoleModel, exchanging accountType to role (as roles is the most common word in user auth systems). |
maybe user groups can take an integer value from less is more privileges have, for example, the admin has a "GID" 0. Only a fuzzy idea. :D |
The way I am currently implementing it in my application is rather simple. I have the Admin Users as the AccountType 1, Then I have Moderators at 2, Members at 3, etc. Then in the authcheck I added another function called groupCheck(); and how it works is I put the Lowest rank I want to be able to access that resource into the function so groupCheck(3); would be members-admin but not guest and banned users. Because the DB already has the AccountType Column it works very well and didn't require any changes to the DB. |
Maybe push it into UserModel. User roles sounds like related to user so maybe that good place. |
I feel like putting roles in to the UserModel is not the right thing to do, You could say that about almost everything, "sounds related to user" however putting everything in the UserModel would make it a mess. i think it should 100% be in a separate model |
I've just pushed little changes to develop branch: The AccountType has now been renamed to UserRole. A super-basic role system incl. role-check will come up (feel free to do this and commit to develop branch if you like). |
Do you want me to do this? have we decided on the best way to implement it? |
@oisian1 Yeah! Feel free to do this, would be very cool! Please do this on develop branch and it would be awesome if you could keep it as simple and as clean as possible. Just a super-simple role system, nothing more. :) Big thanks |
Hi, I'm not a professional programer, but assumed highest user_account_type = highest rights, a very basic way to implement this could be done with the following changes:
to
and after the first "if" statement add:
Now you can easily control the user permission in your controlers by writing:
All users with a lower account type (role/permission) will be redirect to home, or whereever you want them to go to. What do you think? |
Last time I was also looking in something like Admin and two user roles. I stumbled over this discussion: http://stackoverflow.com/questions/3213610/how-to-manage-user-roles-in-a-database |
@Dominic28 Hi, what you used is exactly what i am looking for. I am a bit of a noob with php, but am learning as I go along. Please could you explain to me how you implemented your code. I only use three different groups, and each one needs to see different content. The code i am referring to is: if (Session::get("user_account_type") == Config::get("ADMIN_GROUP")) { I have looked everywhere I can possibly think of but have no idea how or where you created the extra entries in the config-array. I would really appreciate some help on this. |
@stealth027 Just create entries in the config-array with the id of the groups like this: |
@Dominic28 So simple... Awesome! thanks a mill. I really appreciate it. |
There's now an "admin feature" in the develop branch, made in an extremly simple way. This is an external commit, so it's only partly "my" code. Basically it works like this: Beside I know, it's VERY simply and not very modular, but I think it's okay for simple use cases. |
He guys, I'll close this ticket as this feature is partly done, and link this issue from the the new "future feature ideas" section inside the readme. I think it's okay as this is not a real bug or so. |
Hi, i'm not sure if this has been discussed or not yet, but i feel like user roles is part of the user creation/login process. so with a few tweeks to the database to allow roles to be assigned to a user, we could then have a function in the Auth class to check if they have the required roles to view a view or a controller. here is a quick thrown together example
And then in the views or where ever we can simply do something like this.
The text was updated successfully, but these errors were encountered: