Welcome Guest, Not a member yet? Register   Sign In
Community Auth: User Accounts & Groups
#1

I have SaaS-type app in mind where, ideally, I would like to segregate access to certain resources (i.e. designated file stores, databases etc.) based off of what group a user is associated with. So with that in mind...
  • Would I be able to do this using the groups configuration?
  • Can I have the same level/role associated with the different groups I create?
  • If all so, why aren't there any authentication variables to leverage for groups as like the rest?
Lastly, I'm sure this has been asked before, but (I couldn't find a relevant post) how easy would it be to add additional fields to the 'users' table to also capture basic user demographic data such as names, phones, company etc.? Or would simply creating a totally separate able to house that information be recommended? Thanks!
Reply
#2

(11-02-2015, 05:01 PM)8obby6igita1 Wrote: I have SaaS-type app in mind where, ideally, I would like to segregate access to certain resources (i.e. designated file stores, databases etc.) based off of what group a user is associated with. So with that in mind...
  • Would I be able to do this using the groups configuration?
  • Can I have the same level/role associated with the different groups I create?
  • If all so, why aren't there any authentication variables to leverage for groups as like the rest?
Lastly, I'm sure this has been asked before, but (I couldn't find a relevant post) how easy would it be to add additional fields to the 'users' table to also capture basic user demographic data such as names, phones, company etc.? Or would simply creating a totally separate able to house that information be recommended? Thanks!

If you take a look at the way groups work in Community Auth, you'll see that a group is just a set of roles. You get to name your groups whatever you want, and when you authenticate by group, all Community Auth is doing is cross referencing the roles that belong in the group, and then making sure one of those roles matches the user attempting to login. Nothing fancy going on here. So, lets say you have multiple types of employees:


PHP Code:
$config['groups'] = array(
    'employees' => 'cashier,stocker,manager,salesperson,janitor' // Notice this is a comma delimited string
); 

Any role can be a member of any group, just as long as you add it to the comma delimited list. In my apps I've used a group called "Team", which was used for a selection of employees. Another group for higher level employees was named "Management".

While not implemented, it wouldn't be hard to use config_item() to get the groups, then determine if your logged in user is a member of a specific group(s). Because a role can be part of more than one group, you'd probably want to loop through all of the groups to see how many groups the logged in user belongs to. Such a feature has not been added to Community Auth, and probably won't be, unless it is requested by a few individuals.

There aren't auth variables for groups because in the years that I've worked with and used Community Auth, I've never needed such a feature. If you're interested in doing some work and creating a pull request, I wouldn't mind doing something similar for groups, but it's low on my list of things to do.

The previous version of Community Auth implemented user "profiles", and these profiles had data that was stored in separate tables. I've promised to show people how to implement these profiles in the current version of Community Auth, but for now please view the old version to see how it was done.
Reply
#3

FYI, I made a little blog post about profiles today:

http://community-auth.com/blog-posts/int...r-profiles
Reply




Theme © iAndrew 2016 - Forum software by © MyBB