EllisLab text mark
Advanced Search
81 of 89
81
   
Ion Auth - Lightweight Auth System based on Redux Auth 2
Posted: 08 June 2012 07:19 PM   [ # 1201 ]   [ Rating: 0 ]
Joined: 2011-12-22
2 posts
nl_vinyl - 23 May 2012 04:06 AM

I am starting work on an application that will house multiple company’s with multiple users per company.

Depending on what company they work for and what their rights are different data will be loaded.

How suitable is Ion Auth for this? Is there an option for this within Ion Auth? Cause I am guessing the groups are ment for different right sets and not for say company separation?

I’m looking at doing something similar, will need to modify so that a user can be member of multiple companies (which it can switch between), divisions and groups (to limit access).

Curious to know, is Ion Auth in its current state considered production ready?

Thanks. smile

 
Posted: 08 June 2012 07:25 PM   [ # 1202 ]   [ Rating: 0 ]
Avatar
Joined: 2011-02-23
182 posts

Yes. It’s definitely worthy of using anywhere you like. It’s even got MongoDB support now. Looks like you’ve got quite a complex problem at hand (these role and tier systems are much much harder than what they appear on the surface)... IonAuth will not solve all of it, but it’s a good tool.

 Signature 

Circle me on google plus. Follow me on twitter. Look me up on forrst. And check out these superb premium domains that are up for sale.

 
Posted: 08 June 2012 07:35 PM   [ # 1203 ]   [ Rating: 0 ]
Joined: 2011-12-22
2 posts

Thanks. Definitely easier than starting from scratch though. wink

 
Posted: 13 June 2012 11:07 AM   [ # 1204 ]   [ Rating: 0 ]
Avatar
Joined: 2012-06-13
15 posts

Hello!  I’m working on an educational website, an Ion_Auth looks like it can work, I just have a few questions about how groups work and if they are appropriate for what I’m planning.
I need to create three tiers of users:admins, students and teachers.  (Admins already have a category it seems)  It seems that I can use groups to separate teachers from students, but can I also use groups to classify students by their teacher’s ID and their class?  Also, I’ve read the documentation, but is it possible to apply multiple groups to a single user?

 
Posted: 13 June 2012 05:03 PM   [ # 1205 ]   [ Rating: 0 ]
Joined: 2012-06-13
9 posts

Hello everyone, my first post here.

My question is how do you check whether the user IS logged in or not in views. For example if user is logged in i want to show admin options in widget area if he isn’t logged in i want to show just login form in widget area

Few things:
- I don’t want to have multiple views, for example one for admin, one for user, one for guest.
- Right now i’m using this tutorial http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth
- In view files i use (!empty($someuserobject)) to see is he logged in

Is there a better approach?

 
Posted: 13 June 2012 05:29 PM   [ # 1206 ]   [ Rating: 0 ]
Avatar
Joined: 2011-02-23
182 posts
digital_frog - 13 June 2012 11:07 AM

I need to create three tiers of users:admins, students and teachers.  (Admins already have a category it seems)  It seems that I can use groups to separate teachers from students, but can I also use groups to classify students by their teacher’s ID and their class?  Also, I’ve read the documentation, but is it possible to apply multiple groups to a single user?

Well, you can store the teacher’s ID and the class ID in the DB. That’s not something IonAuth can help with, though it’s very simple. Yes, you can have multiple groups for each user.

 Signature 

Circle me on google plus. Follow me on twitter. Look me up on forrst. And check out these superb premium domains that are up for sale.

 
Posted: 13 June 2012 05:36 PM   [ # 1207 ]   [ Rating: 0 ]
Avatar
Joined: 2011-02-23
182 posts
Dinko - 13 June 2012 05:03 PM

My question is how do you check whether the user IS logged in or not in views. For example if user is logged in i want to show admin options in widget area if he isn’t logged in i want to show just login form in widget area

Few things:
- I don’t want to have multiple views, for example one for admin, one for user, one for guest.
- Right now i’m using this tutorial http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth
- In view files i use (!empty($someuserobject)) to see is he logged in

Is there a better approach?

This is what I do:

1. Store $this->ion_auth->user() in a variable in the controller’s __construct() [I use $this->user)
2. Send the user object to the view. Check inside the view if the object exists, output code accordingly.

This seems very similar to what you are doing, and I don’t see why we should search for better approaches when this works perfectly fine…

PS: I just skimmed that tutorial and again that guy seems to be doing the same thing too!

 Signature 

Circle me on google plus. Follow me on twitter. Look me up on forrst. And check out these superb premium domains that are up for sale.

 
Posted: 14 June 2012 04:37 AM   [ # 1208 ]   [ Rating: 0 ]
Joined: 2012-06-13
9 posts
adityamenon - 13 June 2012 05:36 PM
Dinko - 13 June 2012 05:03 PM

My question is how do you check whether the user IS logged in or not in views. For example if user is logged in i want to show admin options in widget area if he isn’t logged in i want to show just login form in widget area

Few things:
- I don’t want to have multiple views, for example one for admin, one for user, one for guest.
- Right now i’m using this tutorial http://jondavidjohn.com/blog/2011/01/scalable-login-system-for-codeigniter-ion_auth
- In view files i use (!empty($someuserobject)) to see is he logged in

Is there a better approach?

This is what I do:

1. Store $this->ion_auth->user() in a variable in the controller’s __construct() [I use $this->user)
2. Send the user object to the view. Check inside the view if the object exists, output code accordingly.

This seems very similar to what you are doing, and I don’t see why we should search for better approaches when this works perfectly fine…

PS: I just skimmed that tutorial and again that guy seems to be doing the same thing too!

Yea, that’s it.

EDIT:

Lil bit off topic but im struggling to get group of a user currenlty logged in.
Code in my controller construct:

$data->the_group $this->ion_auth->get_users_groups()->result();
$this->load->vars($data); 

In my view:

<?php echo $the_group->id?> 

Message: Trying to get property of non-object

EDIT2:

Ok, got it. $data->the_group = $this->ion_auth->get_users_groups()->result();

Chnaged to row()

 
Posted: 14 June 2012 11:28 AM   [ # 1209 ]   [ Rating: 0 ]
Avatar
Joined: 2012-06-13
15 posts
adityamenon - 13 June 2012 05:29 PM
digital_frog - 13 June 2012 11:07 AM

I need to create three tiers of users:admins, students and teachers.  (Admins already have a category it seems)  It seems that I can use groups to separate teachers from students, but can I also use groups to classify students by their teacher’s ID and their class?  Also, I’ve read the documentation, but is it possible to apply multiple groups to a single user?

Well, you can store the teacher’s ID and the class ID in the DB. That’s not something IonAuth can help with, though it’s very simple. Yes, you can have multiple groups for each user.


Ok, one solution is to create an extra row in the database that contains a teacher ID separate from their user ID, and all of their students will have the same teacher ID.  Looking up students by teacher would simply mean matching the teacher’s ID of the student with that of the teacher.  Defining class could just be another row for students as well.  But would it be easier to create a group for every teacher which would define their own students, and then another group based on class?  Instead of using a teacher ID to track students, it would be their teacher’s group.  Also for the class group, it would simply be class1, class2, class3 and so forth, so all students across all teachers can use the same class groups since their teacher group will separate them.

Out of curiosity, are there any tutorials for Ion_auth?  I’ve gone through the documentation, but seeing code in action is the fastest way to learn it sometimes.

 
Posted: 14 June 2012 12:39 PM   [ # 1210 ]   [ Rating: 0 ]
Avatar
Joined: 2011-02-23
182 posts
digital_frog - 14 June 2012 11:28 AM

Out of curiosity, are there any tutorials for Ion_auth?  I’ve gone through the documentation, but seeing code in action is the fastest way to learn it sometimes.

To be fair, Ion_auth is one of the better documented libraries around, the code examples are very clear on what input to give and what output to expect. Dinko’s post above mine has a link to a 3rd party tutorial too.

digital_frog - 14 June 2012 11:28 AM

Ok, one solution is to create an extra row in the database that contains a teacher ID separate from their user ID, and all of their students will have the same teacher ID.  Looking up students by teacher would simply mean matching the teacher’s ID of the student with that of the teacher.  Defining class could just be another row for students as well.  But would it be easier to create a group for every teacher which would define their own students, and then another group based on class?  Instead of using a teacher ID to track students, it would be their teacher’s group.  Also for the class group, it would simply be class1, class2, class3 and so forth, so all students across all teachers can use the same class groups since their teacher group will separate them.

I suppose you can do it this way too. I would personally prefer having IDs to track teacher and class, as I think having so many groups will probably get messy after a while. Especially because I will then need to write code to create groups on demand, edit/delete them (and dealing with all the students they are associated with, and this might even affect classes). I tend to think Groups as a structural support to the data, and don’t want to mess too much with it but only use it as a foundation.

But coding is also about creativity, so go ahead, do what you are thinking, and let us know how you fared! smile

 Signature 

Circle me on google plus. Follow me on twitter. Look me up on forrst. And check out these superb premium domains that are up for sale.

 
Posted: 15 June 2012 12:03 PM   [ # 1211 ]   [ Rating: 0 ]
Avatar
Joined: 2012-06-13
15 posts

While searching for info on Ion_Auth, I came across this, which might be useful to those first installing it:

          http://www.youtube.com/watch?v=amqmhKf4xs4

There is no sound and you’ll have to pause frequently, but it helps with where the files go as well as configuration.

 
Posted: 20 June 2012 09:04 AM   [ # 1212 ]   [ Rating: 0 ]
Joined: 2012-06-07
5 posts

Hello!

Ion Auth can be used with PHP-ActiveRecord?

There is a way to use IonAuth through PHP-activerecord? Anyone has experience on this?

Thanks!

 
Posted: 20 June 2012 02:42 PM   [ # 1213 ]   [ Rating: 0 ]
Avatar
Joined: 2012-06-13
15 posts

I’m trying to figure out some tricks with groups, and here’s what I’ve got so far.  The user’s group data is not stored with the rest of their user data.  There are two tables that define groups, users_groups that lists which groups a user is in, and groups which simply contains the groups’ names and description.  I was going through the basic admin page that came with the Ion_Auth source files and was trying to find out how to add groups to the create user form.  Whenever I tried searching the table name ‘users_groups’ in the code though, I couldn’t find anything.  How can I define which group a user is in aside from the create_user() function?  Also, how can I create new groups from the code?  Is there a create_groups() function?

 
Posted: 21 June 2012 05:28 AM   [ # 1214 ]   [ Rating: 0 ]
Avatar
Joined: 2011-02-23
182 posts

digital_frog, can you please repeat the questions, in a numbered list format?

 Signature 

Circle me on google plus. Follow me on twitter. Look me up on forrst. And check out these superb premium domains that are up for sale.

 
Posted: 21 June 2012 09:35 AM   [ # 1215 ]   [ Rating: 0 ]
Avatar
Joined: 2012-06-13
15 posts

The two questions were basically:
1.  Is there a function that can define/modify and delete groups?
2.  Is there a function that can change which group a user is in?

After some more searching through ion_auth_model.php, I think I may have found the answer to question 2.  I found two public functions add_to_group() and remove_from_group().

Out of curiosity, what does this line of code do that I found in that function:
  $this->trigger_events(‘add_to_group’);

 

 
81 of 89
81