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]
  • #616 / Nov 17, 2010 10:40pm

    Ben Edmunds

    812 posts

    Hey Bernd,

    I’m not sure what’s up with that error. 

    We’re using Ion Auth with CI 2 in Pyro with no issues…


    Let me know if I can help or if you figure out what’s up.  Are you using CI 2 from tip?

  • #617 / Nov 18, 2010 3:18am

    joytopia

    76 posts

    Ben,

    For the latest CI2 I took the download link from Phil’s blog:
    http://philsturgeon.co.uk/news/2010/05/upgrading-to-codeigniter-2.0
    That link takes me to the original download from BitBucket:
    http://bitbucket.org/ellislab/codeigniter/get/tip.zip

    The error came everywhere in my scripts when I called functions of other models or libraries in a constructor. Since with CI 1.72 everything was OK, I thought, that is a problem of CI2, and I changed all constructors in my scripts. Only ION AUTH’s constructor remains and brings that error.

    No idea how to fix it.

    Best regards
    Bernd

  • #618 / Nov 18, 2010 6:31pm

    Thinkers

    3 posts

    I have the same error of joytopia.
    Anyone has managed to resolve the issue?

    I am using CI2 and Ion_auth too.

    For now, simply changing the controller construct from

    function __construct() 
        {
            parent::__construct();
            $this->load->library('ion_auth');
            /*-----------------------------------------*/
            $this->ion_auth->set_error_delimiters('','');
            /*-----------------------------------------*/
            $this->load->model("users_model");
            $this->load->model('messages_model');
            $this->load->helper('url');
            $this->load->helper('breadcrumb_admin');
            $this->load->helper('slug');
            $this->output->enable_profiler($this->config->item('debug_enabled'));
        }

    to

    function __construct() 
        {
            parent::__construct();
            $this->load->library('ion_auth');
            $this->load->model("users_model");
            $this->load->model('messages_model');
            $this->load->helper('url');
            $this->load->helper('breadcrumb_admin');
            $this->load->helper('slug');
            /*-----------------------------------------*/
            $this->ion_auth->set_error_delimiters('','');
            /*-----------------------------------------*/
            $this->output->enable_profiler($this->config->item('debug_enabled'));
        }

    seems to kick the error away.

    EDIT: The issue is still present, so it is not related to the calling order in the controller.

    Would you please check this? I have found no solutions yet.

    Thank you.

  • #619 / Nov 18, 2010 10:30pm

    Andy78

    91 posts

    I’m using the widget plugin from wiredesignz along with ion_auth to create a login widget that displays in a side bar on every page and so far this is working fine apart from an issue with form validation that I cant seem to solve. its to do with this segment of code in the login widget:

    class User_login extends Widget
    {
        function run($visible = True) {
                    
            //check to see if the user is logging in
            if ($this->form_validation->run('login') == true) 
            {             
                if ($this->input->post('remember') == 1) {//check for "remember me"
                    $remember = true;
                }
                else {
                    $remember = false;
                }
                
                if ($this->ion_auth->login($this->input->post('username'), $this->input->post('password'), $remember)) 
                {   //if the login is successful redirect them back to the home page
                
                    $this->session->set_flashdata('message', $this->ion_auth->messages());
                    redirect($this->config->item('base_url'), 'refresh');
                }
                else 
                {    //if the login was un-successful redirect them back to the login page
                    
                    $data['message'] = 'Incorrect username or password. Please try again.';
                   
                  //  $data['message'] = '';
                       $data['username']   = array('name'   => 'username',
                                                  'id'      => 'username',
                                                  'type'    => 'text',
                                                 );
                                                
                    $data['password']   = array('name'    => 'password',
                                                  'id'      => 'password',
                                                  'type'    => 'password',
                                                );
                                                 
                }
            }

    What is happening is if I display a form with form validation on another page of my site and the login widget is also displayed in the side bar, when the form is submitted the message ‘Incorrect username or password. Please try again.’ is always displayed in the login widget even though the login form within the widget is not what was submitted.

    The problem is obviously to do with $this->form_validation->run being in the form and the widget but I thought adding the validation rules into groups would solve this but its not.

    Any ideas?

  • #620 / Nov 19, 2010 1:19am

    Ben Edmunds

    812 posts

    Andy78,

    Please post the solution that we worked out on IRC for the benefit of future readers.  Thanks!

  • #621 / Nov 19, 2010 11:16am

    Andy78

    91 posts

    Although I had set the validation rules in form on the page and in the widget to different validation groups It seems that form validation was running on both the form and widget when only the form in the page was submitted. With advice from ben I made sure that the both forms were separated into different variables and that the forms were also uniquely named. I had not named the forms and I think this is what was causing the problem

    <?php 
            $attributes = array('name' => 'create_account');
            echo form_open("auth/create_account", $attributes );?>

    although I cant be 100% sure as I cant seem to replicate the problem I was having….

    Thanks for your help on IRC ben..no doubt Ill probably harass you again sometime 😉

  • #622 / Nov 19, 2010 1:51pm

    Jods

    2 posts

    Bernd, I’m getting the exact same error when using Ion Auth and the latest tip version of CI2.

    Maybe they’ve changed the load order? The version from ~October 12 was working fine.

  • #623 / Nov 19, 2010 10:46pm

    Andy78

    91 posts

    I now have the problem back with the forgot password screen. I did everything that seemed to solve the problem before yet its still showing “Incorrect username or password. Please try again.” in the widget after refresh.
    Strange issue

  • #624 / Nov 22, 2010 1:40am

    Timothy_

    100 posts

    Hello,

    I appologise if this has been posted already, I have tried searching but I don’t have time to read 63 pages!

    I am registering a user in my own controller using:

    $this->ion_auth->register($username, $password, $email, $additional_data, $group_name)

    How can I retrieve the user_id of the user I just created back from the model?

    I appreciate your help.

    Thanks,

    Tim

  • #625 / Nov 22, 2010 4:10am

    Devon Lambert

    139 posts

    Hello,

    I appologise if this has been posted already, I have tried searching but I don’t have time to read 63 pages!

    I am registering a user in my own controller using:

    $this->ion_auth->register($username, $password, $email, $additional_data, $group_name)

    How can I retrieve the user_id of the user I just created back from the model?

    I appreciate your help.

    Thanks,

    Tim

    Hi Tim,

    There are few different ways to go about the retrieval but it depends on what you’re trying to achieve?

    Looking through the code, the register function will return the user_id of the last created user OR false, if there was an error for some reason.

    Hope this helps?

    - Devon

  • #626 / Nov 22, 2010 4:33am

    Timothy_

    100 posts

    Hello Devon,

    Thanks for replying.

    I have to add some more data to my DB specific to the user right after registering them. I don’t have a lot of experience in passing data back from the model so i’m pretty lost…

    Is there a code example you could point me towards?

    Thanks,

    Tim Mohr

  • #627 / Nov 22, 2010 10:49am

    Devon Lambert

    139 posts

    Hello Devon,

    Thanks for replying.

    I have to add some more data to my DB specific to the user right after registering them. I don’t have a lot of experience in passing data back from the model so i’m pretty lost…

    Is there a code example you could point me towards?

    Thanks,

    Tim Mohr

    Unfortunately, I can’t see any specific function provided by Ion_auth that provides this functionality to your controller. The register function lives within the library and returns the user_id. Someone else may have a better idea for getting at the user_id but it sounds like you may need to modify the library to get what your after.

    Take a look at the below code found within the register function. You’ll see how the devs were able to extract the user_id and store it in a variable to be passed in the event of email activation.

    Found at line 320 in the Ion_auth library.

    $activation_code = $this->ci->ion_auth_model->activation_code;
                $identity        = $this->ci->config->item('identity', 'ion_auth');
                $user            = $this->ci->ion_auth_model->get_user($id)->row();
    
                $data = array(
                    'identity'   => $user->{$identity},
                    'id'         => $user->id,
                    'email'      => $email,
                    'activation' => $activation_code,
                );
  • #628 / Nov 22, 2010 11:15am

    Devon Lambert

    139 posts

    Hey Bernd,

    I’m not sure what’s up with that error. 

    We’re using Ion Auth with CI 2 in Pyro with no issues…


    Let me know if I can help or if you figure out what’s up.  Are you using CI 2 from tip?

    Hey Ben,

    Just another nod for Bernd’s issue. I too am experiencing this issue with the latest/TIP clone from CI. I notice that in Pyro’s dev branch you guys are still using the older CI code in the system folder? Perhaps this is why it is working for you with Pyro?

    Will keep investigating.

  • #629 / Nov 23, 2010 12:31am

    Ben Edmunds

    812 posts

    Timothy_,

    I ran into this problem the other day as well.  I just pushed a change to the library so the register() method will return the newly created users id if the registration was successful, otherwise it will return false.

    So an example of how you get the users id now is:

    $user_id = $this->ion_auth->register(......
  • #630 / Nov 23, 2010 1:21am

    Devon Lambert

    139 posts

    All appears to be working ok now?

    Strange, not really sure what I did. I updated my uri_protocol in my Config file, but hardly see how this could affect/change the error that was being thrown.

    Also went back and re-downloaded the latest tip of CI from BitBucket. This is more likely to be where the solution came from, but I can’t say for sure as I kept working on some other issues.

    I’ll keep an eye out and if this bug returns, I’ll let the group know how I was able to resolve.

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

ExpressionEngine News!

#eecms, #events, #releases