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.

The Easiest Authentication Library for CodeIgniter just got easier.

April 25, 2009 7:12pm

Subscribe [37]
  • #76 / May 28, 2009 6:27pm

    kollo

    1 posts

    After logout I have
    Fatal error: Call to undefined method CI_Session::sess_destroy(), why?

    codeigniter 1.7.1

  • #77 / May 28, 2009 6:46pm

    Adam Griffiths

    316 posts

    After logout I have
    Fatal error: Call to undefined method CI_Session::sess_destroy(), why?

    codeigniter 1.7.1

    Are you using the version from the .zip archive from the CodeIgniter homepage or the svn trunk? Are you using an extended or overridden Session class?

    The user guide shows that the function is sess_destroy() but another user changed it to destroy() and it worked fine.

    It works fine on my server and locally, so I can only imagine you’ve either used an extended Session class or the svn version of CodeIgniter.


    Thanks,
    Adam

  • #78 / May 30, 2009 1:02am

    Jbeasley6651

    22 posts

    This is amazing, keep up the good work. I am able to speed right though adding authentication to my current application, i didn’t have to change my files around to different folders or anything really Just uploaded, configured and was on my way. SO SIMPLE. Thanks!

  • #79 / May 30, 2009 4:43am

    jbawarren

    22 posts

    In the _verify_cookie() private function in libraries/auth, wouldn’t you want the line:

    if ((array_key_exists('login_attempts', $_COOKIE)) && ($_COOKIE['login_attempts'] >= 5)) {

    to read:

    if ((array_key_exists('login_attempts', $_COOKIE)) && ($_COOKIE['login_attempts'] <= 5)) {

    instead? So that login attempts is evaluates if it’s less than 5, So that a new identifier isn’t generated at every request? Or is that the point and maybe I’m just missing something?

  • #80 / May 30, 2009 11:11am

    Jbeasley6651

    22 posts

    I did a quick browse of the thread and didn’t find anyone talking about the bug i found this morning so i’ll post it. (sorry if it’s been posted)

    I was building an app to save the users information into a profile and I was trying to get the logged in users ID, no luck because you need to change the following.

    in Auth.php on line 237 and line 144

    From

    'user_id' => $row['id'],

    to

    'id' => $row['id'],

    the script is writing the column “user_id” to the session data and this is not a valid field in the database. You need to change it to “id”

    Then, if you wanna make it easier on yourself to use the user id in multiple places open up the auth_helper and find this

    function username()
    {
        $CI =& get_instance();
        return $CI->session->userdata('username');
    }

    directly below it add this

    function userid()
    {
        $CI =& get_instance();
        return $CI->session->userdata('id');
    }

    Now, where ever you would like to use the user id you can simple use

    <?php echo userid(); ?>

    Thanks,

    Joel Beasley

  • #81 / Jun 05, 2009 1:38pm

    Adam Griffiths

    316 posts

    The Authentication Library is actually writing the data from id and assigns it to a value in the session for user_id. So you can still grab the id out of the session data at any time.

    Thanks.

  • #82 / Jun 11, 2009 1:43pm

    Dregond Rahl

    85 posts

    Hey Adam, iv been using your library for a project of mine and i noticed that even tho the cookie lasts for ever, the session still dies after 2 hours, and even if i have the cookie it asks me to login. =/

  • #83 / Jun 11, 2009 6:07pm

    markbarratt

    3 posts

    Anyone made a password reminder for this library? Or have a reasonably straightforward method to suggest?

    It’s the one thing missing from this excellent and very simple (in a good way) product.

  • #84 / Jun 14, 2009 12:44pm

    seanloving

    120 posts

    Adam,
    thanks for building this Auth Library.  Hopefully I can adapt it to more than one application.

    This might be more of a CI question than a Auth Library question…

    I modified your register.php (application/views/auth/pages folder) so it includes a select list as follows:

    <input type="text" name="email" size="50" class="form" value="<?php echo set_value('email', $email); ?>" />
    <?php echo form_error('email'); ?>
    
    
    Group:
    
       <select name="group_id">
         <option value="1">Admin</option>
         <option value="2">Sales</option>
         <option value="100">Customer</option>
       </select>

    My Auth.php (application/config folder) contains the group definitions:

    $config['auth_groups'] = array(
                                'admin' => '1',
                                'sales' => '2',
                                'customer' => '100'
                                );

    Then, in the Auth.php (application/libraries folder) I am trying to use the set_select()

    $username = set_value('username');
         $password = $this->_salt(set_value('password'));
         $email = set_value('email');
         //$group = set_select('group_id', '$this->CI->input->post(\'group_id\')');
         $group = $this->CI->input->post('group_id');
         echo $group;  //debug purposes
                
         if($edit === TRUE)
         {
              $this->CI->db->query("UPDATE `users` SET `email` = '$email' WHERE `id` = '$id'");
              $this->CI->db->query("UPDATE `users` SET `group_id` = '$group' WHERE `id` = '$id'");
              $data2['msg'] = "The user has now been edited.";
         }

    Above, I want to use the second $group statement (commented out) not the first one.  How can I make set_select() properly (re)calculate the value to display?  When I use the set_select() the second parameter seems to returns a null (or something similar) because the error message seems to indicate the value is not coming through:

    A Database Error Occurred
    
    Error Number: 1366
    
    Incorrect integer value: '' for column 'group_id' at row 1
    
    UPDATE `users` SET `group_id` = '' WHERE `id` = '5'

    Your set_value seems to be working fine, but my addition of set_select no workie.

    Thanks

    —Sean Loving

  • #85 / Jun 14, 2009 5:07pm

    Adam Griffiths

    316 posts

    Sean, since your dropdown menu is called group_id — wouldn’t the way I’ve grabbed the group_id work anyway?

    Yeah this is more of a CodeIgniter question than an Authentication Library question; and I’m not sure how you’d go about this other than throwing you over to the user guide I’m afraid I won’t be much help with your problem.

    Thanks,
    Adam

  • #86 / Jun 14, 2009 11:32pm

    Hi Adam!

    Do you have an off-line version of your user-guide? I do a great deal of my development on systems without internet access, and that would be extremely useful.

    Thanks anyway, even if you don’t.

  • #87 / Jun 22, 2009 3:47pm

    carnalito

    22 posts

    Hi Adam,

    i think there is another error in the library ‘Auth.php’ line 238:

    Instead:

    $data = array(
                'username' => $username,
                'user_id' => $row['id'],
                'group' => $row['group_id'],
                'logged_in' => TRUE
                );

    it should be:

    $data = array(
                'username' => $username,
                'user_id' => $row['id'],
                'group_id' => $row['group_id'],
                'logged_in' => TRUE
                );

    Right?!

    Regards

    Carnalito

  • #88 / Jun 22, 2009 5:46pm

    Adam Griffiths

    316 posts

    Hi Adam,

    i think there is another error in the library ‘Auth.php’ line 238:

    Instead:

    $data = array(
                'username' => $username,
                'user_id' => $row['id'],
                'group' => $row['group_id'],
                'logged_in' => TRUE
                );

    it should be:

    $data = array(
                'username' => $username,
                'user_id' => $row['id'],
                'group_id' => $row['group_id'],
                'logged_in' => TRUE
                );

    Right?!

    Regards

    Carnalito

    I have fixed this error and it’s in the Github repo. Here. The correct way to reference group is ‘group’ not ‘group_id’.


    Thanks.

  • #89 / Jun 23, 2009 7:02am

    carnalito

    22 posts

    Hi Adam,

    well seems a little weird, check line 145:

    'group_id' => $row['group_id']

    and in line 238 in the same context:

    'group' => $row['group_id']

    i would bet that one line of this two is not correct.
    Maybe i am wrong…

    Regards

    Carnalito

  • #90 / Jun 23, 2009 7:09am

    Adam Griffiths

    316 posts

    Hi Adam,

    well seems a little weird, check line 145:

    'group_id' => $row['group_id']

    and in line 238 in the same context:

    'group' => $row['group_id']

    i would bet that one line of this two is not correct.
    Maybe i am wrong…

    Regards

    Carnalito

    I have no idea why this is the case. My last commit to Github fixed this issue. I’ll push all the files again.

    Thanks.

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

ExpressionEngine News!

#eecms, #events, #releases