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]
  • #1216 / Jun 21, 2012 9:35am

    digital_frog

    14 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’);

     

  • #1217 / Jun 21, 2012 10:27am

    adityamenon

    175 posts

    1. I don’t think that exists - you will need to do it manually. And there’s a issue in the github regarding deleting groups, especially what happens to the users inside. I’ll have to commit sometime now 😊

    2. Yes, use a combination of add_to and remove_from for editing group membership

    Trigger events has been explained by Ben before, here: https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/220 and here: https://github.com/benedmunds/CodeIgniter-Ion-Auth/issues/240

  • #1218 / Jun 22, 2012 6:18pm

    sevengraff

    5 posts

    Anyone familiar with how to tell how many users are loged in right now? Like get a list of everyone who logged in today/yesterday or some time limit?

    I see that the users table keeps track of the last login, but I don’t see when this is updated.

  • #1219 / Jun 26, 2012 11:33am

    digital_frog

    14 posts

    sevengraff, it may be possible to search the database by date to see who is logged.  Adding a logged-in flag to the user table may also work, but I’m pretty sure something may already exist with how the sessions work that may do that.


    On another note, I may have found a bug with how log-ins are handled.  While I was testing account permissions on pages, I was able to access my admin page from an account classified as a student.  (These are set by the built in group functions)  I was logged in as the administrator before I logged in as the student, but I never logged out of the admin account.  I think it may be possible to be logged in a two users at once, either that or the student account session somehow inherited something from the admin session.  Once I cleared my cookies, the student account no longer had access to the page.  Of course I will not be enabling the login box if there is a user logged in, but I thought this would be something worth mentioning.

  • #1220 / Jun 26, 2012 4:05pm

    digital_frog

    14 posts

    I kind of broke my site with this, and was wondering if anyone knows what to do. 

    I have installed Ion_Auth into my site to replace a simple login I made from a tutorial video.  The install worked and I began the process of converting the site to use Ion_Auth, so teacher/student and admin pages are protected by groups now, and logging in works from [http://localhost/example/auth/login]

    The problem comes from trying to make logging in from the site main page instead of auth/login page.  When I try to load the auth/login view into site.php, it gives me these error messages when I access the site:


    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: message

    Filename: auth/login.php

    Line Number: 7

    Email/Username:
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: identity

    Filename: auth/login.php

    Line Number: 13

    Password:
    A PHP Error was encountered

    Severity: Notice

    Message: Undefined variable: password

    Filename: auth/login.php

    Line Number: 18


    My front page is created by site.php, and auth.php is a separate controller.  I tried copy/pasting auth.php into site.php, but that didn’t seem to work.  (My logic being that everything should be defined auth.php)  I am still fairly new to codeigniter and therefore this may just be some n00bish mistake I’m overlooking.

    ======================================================================================
    EDIT:  Ok, I solved the problem, it was indeed a simple n00bish mistake.
    I had simply forgot to route the form in my login_view properly.  My old form_open linked to admin.php which handled the login process, but I only changed it to form_open(‘auth’) instead of form_open(‘auth/login’).  I figured I would leave this post here for any others that get stuck by anything similar.

  • #1221 / Jun 28, 2012 4:03am

    Zaher Ghaibeh

    48 posts

    @digital_frog your problem is that your using the controller without making sure that the vars inside your view is really the same as the one you use in your controller ..

    for example :

    Message: Undefined variable: password

    mean that you have a password variable in your view which is not defined inside your controller and if it is, you didnt pass it to your view ..

    all of your problem are the same

  • #1222 / Jul 02, 2012 1:15am

    sirvoo

    2 posts

    I’ve installed Ion Auth. I am able to register and log in but I don’t receive any emails when I register or reset the password.

    Do I need to set this anywhere?

    I’ve create email.php in the config folder. I’ve tried

    $config['protocol'] = 'mail';

    and

    $config['protocol']='smtp';
    
    $config['smtp_host']='ssl://smtp.googlemail.com'; //(SMTP server)
    
    $config['smtp_port']='465'; //(SMTP port)
    
    $config['smtp_timeout']='30';
    
    $config['smtp_user']='email'; //(.(JavaScript must be enabled to view this email address))
    
    $config['smtp_pass']='password'; // (gmail password)
    
    
    $config['mailtype'] = 'html';
    $config['charset'] = 'utf-8';
    $config['newline'] = "\r\n";

    config/ion_auth.php

    $config['use_ci_email'] = FALSE; // Send Email using the builtin CI email class, if false it will return the code and the identity
    //$config['email_config'] = array(
    // 'mailtype' => 'html',
    //);
    $config['email_config'] = 'email';
  • #1223 / Jul 02, 2012 1:44am

    adityamenon

    175 posts

    I’ve installed Ion Auth. I am able to register and log in but I don’t receive any emails when I register or reset the password.

    Do I need to set this anywhere?

    I’ve create email.php in the config folder. I’ve tried

    $config['protocol'] = 'mail';

    and

    $config['protocol']='smtp';
    
    $config['smtp_host']='ssl://smtp.googlemail.com'; //(SMTP server)
    
    $config['smtp_port']='465'; //(SMTP port)
    
    $config['smtp_timeout']='30';
    
    $config['smtp_user']='email'; //(.(JavaScript must be enabled to view this email address))
    
    $config['smtp_pass']='password'; // (gmail password)
    
    
    $config['mailtype'] = 'html';
    $config['charset'] = 'utf-8';
    $config['newline'] = "\r\n";

    config/ion_auth.php

    $config['use_ci_email'] = FALSE; // Send Email using the builtin CI email class, if false it will return the code and the identity
    //$config['email_config'] = array(
    // 'mailtype' => 'html',
    //);
    $config['email_config'] = 'email';

    Did you make the changes to the settings as described in the comments within the code?

  • #1224 / Jul 02, 2012 2:13am

    sirvoo

    2 posts

    Did you make the changes to the settings as described in the comments within the code?

    Are you referring to:

    $config['smtp_user']='email'; //(.(JavaScript must be enabled to view this email address))
    
    $config['smtp_pass']='password'; // (gmail password)

    Yes I did input the correct details

  • #1225 / Jul 02, 2012 3:39am

    adityamenon

    175 posts

    This is very probably an issue of the server unable to send emails, rather than CI or IAuth. A suggestion: replace with $config[‘use_ci_email’] = TRUE, and save a file called email.php inside application/config/ and autoload the email library within application/config/autoload.php

    Then write a little file to test the CI email functionality. Use $this->email->print_debugger(); to know what’s going wrong…

    If nothing is going wrong, the next time you try to register the emails should go out properly.

  • #1226 / Jul 06, 2012 2:49pm

    digital_frog

    14 posts

    I’m trying to create a function that displays data that the currently logged in user has in a table separate from the ion_auth users.  The table has three columns:[id (the primary key)], [uid (which matches the users id)], and [items (what the user currently has)].  The problem is that I can’t seem to get at the current user’s id.

    How can I get the user’s id from ion_auth?
    I tried using

    $user = $this->ion_auth->get_user();

    from the start of this thread but this is throwing errors.
    I’ve also tried using $user_id = $this->session->userdata( ‘id’ );
    to try to get the data from the session, but that has only returned zero.

  • #1227 / Jul 06, 2012 3:13pm

    digital_frog

    14 posts

    I’m trying to create a function that displays data that the currently logged in user has in a table separate from the ion_auth users.  The table has three columns:[id (the primary key)], [uid (which matches the users id)], and [items (what the user currently has)].  The problem is that I can’t seem to get at the current user’s id.

    How can I get the user’s id from ion_auth?
    I tried using

    $user = $this->ion_auth->get_user();

    from the start of this thread but this is throwing errors.
    I’ve also tried using $user_id = $this->session->userdata( ‘id’ );
    to try to get the data from the session, but that has only returned zero.

    Funny how working for however long on a problem does so little, yet five minutes after asking the answer is discovered.  Here is the solution:

      $user = $this->ion_auth->user()->row();
      $user_id = $user->id;

  • #1228 / Jul 06, 2012 9:06pm

    adityamenon

    175 posts

    Funny how working for however long on a problem does so little, yet five minutes after asking the answer is discovered.  Here is the solution:

      $user = $this->ion_auth->user()->row();
      $user_id = $user->id;

    Haha yes, ion_auth autoloads classes from the model when it receives requests for classes that do not exist in the library. So you need to assume the returned data will be in a CodeIgniter database object. Also, I’m not trying to flame you, but always read the Ionauth user guide + search the issue queues + this forum thread with google any time you see a sticky problem, instead of trying to solve it for hours. Chances are someone has already faced it and that will save you a lot of time 😊 This is really not so obvious (even for me the advise troll) and people always tend to try and solve it for themselves!

  • #1229 / Jul 08, 2012 2:12am

    Kostya1111

    2 posts

    Hi all,

    I’ve read previous comments but my questions have not disappeared.

    I watch in source code of library and don’t understand why it works:

    $this->ion_auth->users()->result();


    It is string from sample controller auth.php

    In src file of library is not method users();. Where is it?
    why methods are not in the file application/library/ion_auth.php?
    What is a magic autoload?

    Thanks

  • #1230 / Jul 08, 2012 3:02am

    adityamenon

    175 posts

    What is a magic autoload?

    Magic Autoload : http://php.net/manual/en/language.oop5.autoload.php

    The methods are in application/models/ion_auth_model.php - which is why you need to call ->result() on those functions just like any normal Codeigniter ActiveRecord objects.

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

ExpressionEngine News!

#eecms, #events, #releases