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]
  • #766 / Feb 18, 2011 10:36pm

    Glazz

    170 posts

  • #767 / Feb 19, 2011 4:17pm

    fran-quero

    19 posts

    Hello. Congratullations for this great library.

    I´m new in CI and I´m testing Ion Auth in a test application.

    I´d like to set access based on groups.

    1. I haven´t see that in the code. Is there any pre-made function or way to do it?

    2. If there isn´t, please, check my code to know if I have done a good practice, or if there´s a better way to do it:

    I have added a function to ion_auth_model.php to control if the user´s group is allowed to acces and optionally if the user have made a payment (in my application there are free and payments users)

    ion_auth_model.php

    public function access($allowed_group,$check_payment=false)
        {
            if($user=$this->ion_auth->get_user())
            {
                if($user->group_id>=$allowed_group)
                {
                    if($check_payment)
                    {
                        if($user->payment)
                        {
                            return true;
                        } else {
                           redirect('welcome');
                        }
                    } else {
                        return true;
                    }
                } else {
                    redirect('welcome');
                }
            } else {
                redirect('auth','refresh');
            }
        }

    When I want to set the access level to a controller I add:

    $this->ion_auth->access(2,true);//Grant access to users from group 2 or higher who have paid

    I´m new in CI and in MVC, is that a good practice? Is there a better way to do this?

    Thanks for your advice.

  • #768 / Feb 19, 2011 4:20pm

    c77m

    20 posts

    @c77m - The fix: https://bitbucket.org/ellislab/codeigniter/issue/252/undefined-method-error-produced-when-using

    Glazz, thanks for the link.  I’m very much opposed to hacking the CI core to hide a library bug, but this link will hopefully help me track down the offending code in the library when I have a few more minutes.

  • #769 / Feb 19, 2011 4:24pm

    c77m

    20 posts

    Hello. Congratullations for this great library.

    I´m new in CI and I´m testing Ion Auth in a test application.

    I´d like to set access based on groups.

    1. I haven´t see that in the code. Is there any pre-made function or way to do it?

    fran-quero,

    There is already a function, is_group(), that will check group membership for you.  (http://benedmunds.com/ion_auth/#is_group)

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

    As written, this will always return true.  😉

  • #770 / Feb 19, 2011 5:52pm

    fran-quero

    19 posts

    There is already a function, is_group(), that will check group membership for you.  (http://benedmunds.com/ion_auth/#is_group)

    Thanks! I should have read more :red:

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

    As written, this will always return true.  😉

    No if the user is not logged in. I use it to check it. Now I will combine logged_in() + is_group().

    Thanks again!

  • #771 / Feb 20, 2011 8:19pm

    Ben Edmunds

    812 posts

    Thanks to harryxu we now have a fix for this without modifying the core: https://bitbucket.org/ellislab/codeigniter/issue/252/undefined-method-error-produced-when-using 

    I just pushed this up to github, enjoy!

  • #772 / Feb 24, 2011 8:52am

    Cristian Gilè

    377 posts

    Hi guys,

    I’m using ion auth in one of my projects and I have a doubt:

    if a logged in user update his email address but he types a bad email, how can he reset a forgetten password ? Is there a method in ion auth to confirm an updated email ?


    Cristian Gilè

  • #773 / Feb 24, 2011 8:47pm

    Ben Edmunds

    812 posts

    Cristian,

    No there’s not.  That’s a tough situation because usually if you are resetting your email it’s because you can’t access the old email (example = changing companies)...

  • #774 / Feb 25, 2011 4:25am

    Cristian Gilè

    377 posts

    Is it a planned feature ?


    Cristian Gilè

  • #775 / Feb 26, 2011 11:14am

    Ben Edmunds

    812 posts

    Cristian,

    No.  Feel free to code it up and send me a pull request though.

  • #776 / Mar 01, 2011 7:41am

    Wayne Smallman

    176 posts

    Hi everyone

    I was playing around with the CI2, Modular Extensions and Ion Auth
    This is what I did to get it working

    1. Get tip_codeigniter.zip (CI2.0)
    2. Extract, make sure it is running, set config.php
    3. Get Modular Extension
      http://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc/wiki/Home
    4. Install - Copy MY_Loader & MY_Router to core, MX to third party folder
      Do not copy MY_Controller - this is for Modular Separation and not Extensions
    5. Get Ion_Auth
      http://github.com/benedmunds/CodeIgniter-Ion-Auth
    6. Install the sql
    7. Put ion_auth into a modules folder /application/modules/users
    8. Add route
      $route[‘auth/(.*)’] = ‘users/auth/$1’; 
    9. Autoload ion_auth
      $autoload[‘libraries’] = array(‘database’,‘session’,‘users/ion_auth’);
    10. Edit paths
          $this->ci->load->config(‘users/ion_auth’, TRUE);
          $this->ci->load->library(‘email’);
          $this->ci->load->library(‘session’);
          $this->ci->lang->load(‘users/ion_auth’);
          $this->ci->load->model(‘users/ion_auth_model’);

    Just in case anyone was trying… 😊

    Hi and thanks for the instructions.

    I’m trying to coerce Ion Auth into working with Modular Extensions on CodeIgniter 2 and I simply cannot get anything working.

    #7 — do you mean, just place all of the files for Ion Auth in there “flat”, or in their respective folders (“config”, “controllers”, “models”, “libraries” et cetera)?

    #10 — would that be anywhere there are similar references, or just one particular file?

  • #777 / Mar 01, 2011 10:33am

    Ben Edmunds

    812 posts

    Wayne,

    In their respective folders.

    All of loading file references should be in the library.

  • #778 / Mar 01, 2011 10:39am

    Wayne Smallman

    176 posts

    Wayne,

    In their respective folders.

    All of loading file references should be in the library.

    Hi Ben, and thanks for the reply!

    I’m getting various errors, specifically:

    The configuration file users/ion_auth.php does not exist.

    Yet if I put the exact path in there: “users/config/...” I still get an error, which I suspect is as a result of the routing.

    I get the same error for every line where I’ve added in “users” to the path name.

  • #779 / Mar 01, 2011 1:13pm

    Ben Edmunds

    812 posts

    Wayne,

    Post a screenshot of your file structure and pastie your library contructor.  Also, make sure you’re not autoloading anything but the library.

    You can also check out PyroCMS if you want to see it in a working environment.

  • #780 / Mar 01, 2011 4:06pm

    Wayne Smallman

    176 posts

    Wayne,

    Post a screenshot of your file structure and pastie your library constructor. Also, make sure you’re not autoloading anything but the library.

    You can also check out PyroCMS if you want to see it in a working environment.

    I’ve looked at three different applications using Modular Extensions and none of them are even remotely alike, and only one has a recognizable structure consistent with the installation instructions for Modular Extensions.

    I’ve followed the previous instructions (the ones I quoted in my first post in this thread, to which you replied) to the letter, so that will save a screen shots and such.

    What library constructor? Keep in mind that I’m trying to learn Modular Extensions, understand all of the changes in CodeIgniter 2 and make the whole thing work with Ion Auth.

    For completeness, I’ve built up the screen shot you requested…

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

ExpressionEngine News!

#eecms, #events, #releases