ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Ion Auth - Lightweight Auth System based on Redux Auth 2

February 10, 2010 7:00pm

Subscribe [287]
  • #1201 / May 30, 2012 5:21am

    Keloo

    15 posts

    And to clear up some confusion, any calls made to the library, eg $this->ion_auth->login(), will automatically be passed through to the model if it’s not found in the library.  This is standard for PHP 5 apps to use overloading but seems to be confusing to people that are either new or used to using PHP 4.

    Thanks for clearing this out for me. Even though I started learning php more then a year ago I didn’t know about this, gotta learn more PHP5.

    I’ve tried sending emails using the CI email library and it worked, but when I try using it with Ion_auth I get all sorts of erros, like:

    A PHP Error was encountered

    Severity: Warning

    Message: fsockopen() [function.fsockopen]: unable to connect to ssl://smtp.googlemail.com:465 (Unable to find the socket transport “ssl” - did you forget to enable it when you configured PHP?)

    Filename: libraries/Email.php

    Line Number: 1689

    A PHP Error was encountered

    Severity: Warning

    Message: fwrite() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1846

    A PHP Error was encountered

    Severity: Warning

    Message: fgets() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1869

    A PHP Error was encountered

    Severity: Warning

    Message: fwrite() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1846

    A PHP Error was encountered

    Severity: Warning

    Message: fgets() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1869

    A PHP Error was encountered

    Severity: Warning

    Message: fwrite() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1846

    A PHP Error was encountered

    Severity: Warning

    Message: fgets() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1869

    A PHP Error was encountered

    Severity: Warning

    Message: fwrite() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1846

    A PHP Error was encountered

    Severity: Warning

    Message: fgets() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1869

    A PHP Error was encountered

    Severity: Warning

    Message: fwrite() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1846

    A PHP Error was encountered

    Severity: Warning

    Message: fwrite() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1846

    A PHP Error was encountered

    Severity: Warning

    Message: fgets() expects parameter 1 to be resource, boolean given

    Filename: libraries/Email.php

    Line Number: 1869

    I’m using the same config like in the older project. Maybe it doesn’t work this way because I’m using the latest CI version, and they’ve changed something.

    Else I can’t explain why it doesn’t work.

  • #1202 / Jun 08, 2012 7:19pm

    maccrazy

    2 posts

    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. 😊

  • #1203 / Jun 08, 2012 7:25pm

    adityamenon

    175 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.

  • #1204 / Jun 08, 2012 7:35pm

    maccrazy

    2 posts

    Thanks. Definitely easier than starting from scratch though. 😉

  • #1205 / Jun 13, 2012 11:07am

    digital_frog

    14 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?

  • #1206 / Jun 13, 2012 5:03pm

    Dinko

    7 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?

  • #1207 / Jun 13, 2012 5:29pm

    adityamenon

    175 posts

    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.

  • #1208 / Jun 13, 2012 5:36pm

    adityamenon

    175 posts

    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!

  • #1209 / Jun 14, 2012 4:37am

    Dinko

    7 posts

    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()

  • #1210 / Jun 14, 2012 11:28am

    digital_frog

    14 posts

    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.

  • #1211 / Jun 14, 2012 12:39pm

    adityamenon

    175 posts

    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.

    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! 😊

  • #1212 / Jun 15, 2012 12:03pm

    digital_frog

    14 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.

  • #1213 / Jun 20, 2012 9:04am

    Sangar

    3 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!

  • #1214 / Jun 20, 2012 2:42pm

    digital_frog

    14 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?

  • #1215 / Jun 21, 2012 5:28am

    adityamenon

    175 posts

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

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases