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]
  • #676 / Dec 06, 2010 8:35pm

    Todlerone

    63 posts

    Todlerone,

    Just the scope of the variable.  $this->data can be accessed from any class method while $data can only be accessed in the current method.

    Ty again Ben.  When I try to use the $this->user[‘username’] I get a NULL value when inserting into the model.

    Cheers…

  • #677 / Dec 06, 2010 9:12pm

    33cent

    26 posts

    Ben,

    do you have planned to implement a user ban feature in one of the following versions?

    “user active” works well, but missing some important info, when deleted or banned user try to login,
    but they dont have detailed info of account status.

  • #678 / Dec 06, 2010 10:13pm

    Ben Edmunds

    812 posts

    Todlerone,

    I’ll need to see your code.

  • #679 / Dec 06, 2010 10:13pm

    Ben Edmunds

    812 posts

    33cent,

    Not really.  I would add meta data for that if I was you.

  • #680 / Dec 07, 2010 6:22am

    33cent

    26 posts

    Thanks for reply,

    i will try to do it, like you said.

  • #681 / Dec 07, 2010 5:07pm

    Todlerone

    63 posts

    Hello everyone.  Sorry for the simple questions.  I’ve successfully implemented Ion Auth as a log in.  Works great.  Now I’m trying to add some functionality to my website.  I have a model that stores personal information (limited).  All I’m trying to do is add their username to the table (not through a form) for creating/editing the data.  The form doesn’t error but the $user[‘username’] comes up empty.  Sorry I don’t have the code (it’s at work).  What is the difference between passing variables with $data[‘username’] and $this->data[‘username’]?

    TY

    Ty Ben.  I worked at this for sometime and eventually got it to work.  I now understand what I had done wrong.  I am however still stuck at the dropdown menu for the create user.  I redid the user login form in code I was familiar with but still don’t get anything listed.

    function create_user(){ 
    //other standard code from this controller here
    if ($this->form_validation->run() == true && $this->ion_auth->register($username,$password,$email,$additional_data)) { //check to see if we are creating the user
                      //redirect them back to the admin page
                    $this->session->set_flashdata('message', "User Created");
                   redirect("admin/admin_main/get_users_array", 'refresh');
            }else{ //display the create user form
                   //set the flash data error message if there is one
                    $this->data['groups'] = $this->ion_auth_model->get_groups();
                
                $this->data['message'] = (validation_errors() ? validation_errors() : ($this->ion_auth->errors() ? $this->ion_auth->errors() : $this->session->flashdata('message')));
                
                $data['user'] = $this->ion_auth->get_user_array();
                $this->title="Create User";    
                $this->thisPage="Admin";
                $this->load->view('header', $data);
                $this->load->view('admin/admin_create_user', $this->data);
                $this->load->view('sidebars/sidebar_admin_main');
                $this->load->view('footer');
            }
        }// end create_user()
    
    
    //the view form
    
    <div class="post">
            <h1 class="title">Add user to JCC Database. </h1>
            <?php echo validation_errors(); ?>
            <?php echo form_open('admin/admin_main/create_user'); ?>
            <fieldset>
                <legend>Personal Information</legend>
                <label for="first_name">First Name:</label>
                    <input type="text" name="first_name" value="<?php echo set_value('first_name'); ?>"/>
    
                <label for="last_name">Last Name:</label>
                    <input type="text" name="last_name" value="<?php echo set_value('last_name'); ?>" />
    
                <label for="group_id">Group Member:</label>
                    <select name="group_id"><option value=''>Choose a group…</option>
                    <?php foreach ($groups as $grp){?>
                    <?php echo "<option value='".$grp['id']."' >".$grp['description']."</option>"; ?>
                    <?php } ?></select>
                        
                <label for="jcc_demo_Gender">Password:</label>
                    <input type="password" name="password" value="<?php echo set_value('password'); ?>" />
    
                <label for="jcc_demo_DOB">Confirm Password:</label>
                    <input type="password" name="password_confirm"  value="<?php echo set_value('password_confirm'); ?>" />
            </fieldset>
            <input type="submit" name="Submit" value="Create User" class="button" /></p>
            </form>
    </div><!-- end #post -->


    TY for your time

  • #682 / Dec 08, 2010 9:40pm

    Ben Edmunds

    812 posts

    The first issue is that you are referencing the groups inside your foreach (grp) as an array when they are an object.

    Whenever you have issue like this you need to troubleshoot it.  Just start with a print_r or var_dump of what your having an issue with and drill down from there.

  • #683 / Dec 14, 2010 3:00pm

    ci_lover

    3 posts

    Hello everybody, great thread.

    I have a question, how do I get all logged in users ?

    Is there a way to pass a user’s id, to the function:

    ion_auth->is_logged();

    for example it becomes:

    ion_auth->is_logged(user_id);


    This would be helpful.

    Thanks.

  • #684 / Dec 16, 2010 2:13am

    Ben Edmunds

    812 posts

    If you use DB sessions you should could query your sessions table.

  • #685 / Dec 16, 2010 2:56am

    ci_lover

    3 posts

    That’s a new idea, I didn’t think of that ..

    I ended up making another DB table for online users.

    Great work you done here Ben. Thanks a lot.

  • #686 / Dec 16, 2010 3:26pm

    mhamp

    1 posts

    Hello everyone!

    First of all, I want to thank you for your great library!
    I’m using it for my current project and I’m very pleased with it…

    But I have one question:
    When a user changes his/her email address, is it possible that he needs to confirm the new address before it’s inserted into the database?

    Thank you 😊

    mhamp

  • #687 / Dec 18, 2010 6:33am

    xatrix

    12 posts

    Once the user is logged in, here’s how to redirect him to the page that required auth.

    In Ion_Auth.php

    public function logged_in()
        {
            $this->ci->session->set_flashdata('referrer', current_url());
            $identity = $this->ci->config->item('identity', 'ion_auth');
    
            return (bool) $this->ci->session->userdata($identity);
        }

    In Auth.php

    if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'), $remember))
                { //if the login is successful
                    //redirect them from whence they came
                    $this->session->set_flashdata('message', $this->ion_auth->messages());
                    redirect($this->session->flashdata('referrer'));
                }
    }

    Basically it will only set flashdata when it has to check if the user is logged in, and redirect when he is.

    Also in your Auth.php, loading a view counts as a server request. So before you load the login view, tell CI to keep the data:

    $this->session->keep_flashdata('referrer');
    $this->load->view('auth/login', $this->data);

    * however, I’m not sure what happens if you call logged_in multiple times. There must be some way to check that flashdata has been set, so that the same key isn’t overwritten (is that even possible?) and reduce code crap. Any ideas?

  • #688 / Dec 18, 2010 8:12pm

    rhussain

    2 posts

    Hi Ben,

    I’ve noticed that the session library is loaded a few times in Ion_Auth.
    It’s loaded in the library class constructor and in the model and in auth.php(which I assume is just example code on how to use Ion_Auth - am I right there?).

    Is it necessary to do this in all three files?

    Can I just have the session library loaded by Ion_auth.php and get rid of the call from auth.php and ion_auth_model.php? Or is one of the other files more suitable?

    I know it’s not that much trouble cos extra calls to the session class are ignored but I suppose I’m a bit picky about that sort of thing…  😊

    I have tried it as described above and it seems to work but I am new to CI and Ion_Auth so I wondered if there would be any deeper impliactions.

    Thanks for Ion_Auth by the way its been a great help!!!

  • #689 / Dec 22, 2010 10:10pm

    kikz4life

    77 posts

    hi there Ben Edmunds,

    first of all adv meri xmas. ^_^.

    i have a slight problem. I’m read almost all the threads in your ionAuth before using your library. I’ve encountered a problem when i created a new user then tried to login, the page just keep refreshing. No output error just the page keeps refreshing. Tried in FF, chrome and IE.

    Anyone else encountered this?

  • #690 / Dec 23, 2010 4:08am

    chenda0331

    2 posts

    Thank you for giving me this! That’s what I need!

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

ExpressionEngine News!

#eecms, #events, #releases