CodeIgniter Forums
Community Auth : Login Error - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forumdisplay.php?fid=7)
+--- Forum: Addins (https://forum.codeigniter.com/forumdisplay.php?fid=13)
+--- Thread: Community Auth : Login Error (/showthread.php?tid=68429)



Community Auth : Login Error - Pawan - 07-10-2017

Im Having a problem with login. It was working perfectly fine until i made the login as default controller page. but now it not working. I tried updating the password still no success.



Here is My Log file

DEBUG - 2017-07-10 11:51:41 --> Total execution time: 0.1743
DEBUG - 2017-07-10 11:51:42 --> UTF-8 Support Enabled
DEBUG - 2017-07-10 11:51:42 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2017-07-10 11:51:42 --> Config file loaded: C:\wamp64\www\webaccounts\application\config/db_tables.php
DEBUG - 2017-07-10 11:51:42 --> Config file loaded: C:\wamp64\www\webaccounts\application\third_party/community_auth/config/db_tables.php
DEBUG - 2017-07-10 11:51:42 --> Config file loaded: C:\wamp64\www\webaccounts\application\config/authentication.php
DEBUG - 2017-07-10 11:51:43 --> Config file loaded: C:\wamp64\www\webaccounts\application\third_party/community_auth/config/authentication.php
DEBUG - 2017-07-10 11:51:43 --> Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.
DEBUG - 2017-07-10 11:51:43 --> Encryption: Auto-configured driver 'openssl'.
DEBUG - 2017-07-10 11:51:43 --> Session class already loaded. Second attempt ignored.
DEBUG - 2017-07-10 11:51:43 --> Tokens class already loaded. Second attempt ignored.
DEBUG - 2017-07-10 11:51:43 --> Authentication class already loaded. Second attempt ignored.
DEBUG - 2017-07-10 11:51:43 -->
 string     = skunkbot
 password   = pawan1212
 form_token =
 token_jar  = ["fa72f57a","48602bf2","8ccfde89","dc3284ed","14891698","1a2545eb","c3f39347","24ef42bf","db139efa","74167e56","c20f513d"]



Controller
    
Code:
public function login()
    {
        if( $this->uri->uri_string() == 'app/login')
            show_404();
        if(!$this->verify_min_level(1) || !$this->verify_min_level(3) || !$this->verify_min_level(6))
        {
        $this->is_logged_in();
        $this->tokens->name = 'login_token';
        if( $this->authentication->on_hold === TRUE )
        {
            $data['on_hold_message'] = 1;
        }

        // This check for on hold is for normal login attempts
        else if( $on_hold = $this->authentication->current_hold_status() )
        {
            $data['on_hold_message'] = 1;
        }

        $link_protocol = USE_SSL ? 'https' : NULL;
        $html = $this->load->view('login/login', '', TRUE);

        echo $html;
        }
    }
    /**
    
    Ajax Login
    */
    
    public function ajax_attempt_login()
    {
        
        if( $this->input->is_ajax_request() )
        {
            // Allow this page to be an accepted login page
            $this->config->set_item('allowed_pages_for_login', ['app/ajax_attempt_login'] );
            // Make sure we aren't redirecting after a successful login
            $this->authentication->redirect_after_login = FALSE;

            // Do the login attempt
            $this->auth_data = $this->authentication->user_status( 0 );

            // Set user variables if successful login
            if( $this->auth_data )
                $this->_set_user_variables();

            // Call the post auth hook
            $this->post_auth_hook();

            // Login attempt was successful
            if( $this->auth_data )
            {
                echo json_encode([
                    'status'   => 1,
                    'user_id'  => $this->auth_user_id,
                    'username' => $this->auth_username,
                    'level'    => $this->auth_level,
                    'role'     => $this->auth_role,
                    'email'    => $this->auth_email
                ]);
            }

            // Login attempt not successful
            else
            {
                $this->tokens->name = 'login_token';

                $on_hold = (
                    $this->authentication->on_hold === TRUE OR
                    $this->authentication->current_hold_status()
                )
                ? 1 : 0;

                echo json_encode([
                    'status'  => 0,
                    'count'   => $this->authentication->login_errors_count,
                    'on_hold' => $on_hold,
                    'token'   => $this->tokens->token()
                ]);
            }
        }

        // Show 404 if not AJAX
        else
        {
            show_404();
        }
    }

View

Code:
<form id="login_from" method="POST">

         <fieldset class="clearfix">

           <p><span class="fa fa-user"></span><input type="text" <input type="text" name="login_string" id="login_string" class="form_input" autocomplete="off" maxlength="255" Placeholder="Username" required></p> <!-- JS because of IE support; better: placeholder="Username" -->
           <p><span class="fa fa-lock"></span><input type="password" type="password" name="login_pass" id="login_pass" autocomplete="off" readonly="readonly" onfocus="this.removeAttribute('readonly');" Placeholder="Password" <?php if( config_item('max_chars_for_password') > 0 ) echo 'maxlength="' . config_item('max_chars_for_password') . '"'; ?> required></p> <!-- JS because of IE support; better: placeholder="Password" -->
            <input type="hidden" id="max_allowed_attempts" value="<?php echo config_item('max_allowed_attempts'); ?>" />
            <input type="hidden" id="mins_on_hold" value="<?php echo ( config_item('seconds_on_hold') / 60 ); ?>" />
           <?php
            if( config_item('allow_remember_me') )
                {
            ?>
           <p> <label class="checkbox-inline"><input type="checkbox" id="remember_me" name="remember_me" value="yes" />Remember Me</label></p>
            <?php
                }
            ?>



RE: Community Auth : Login Error - skunkbad - 07-10-2017

You need to either use the form_open function or manually include the token in a hidden input.


RE: Community Auth : Login Error - Pawan - 07-10-2017

(07-10-2017, 07:33 AM)skunkbad Wrote: You need to either use the form_open function or manually include the token in a hidden input.

Thanks it worked !!!!


RE: Community Auth : Login Error - Pawan - 07-10-2017

thanks it worked for me. 

Now help me with other one I just updated authentication.php in config for user level and roles after that i m getting this error . I already updated new value in DB and Clear cache as well as Session still facing issue in auth_controller . Please Point the error where i m wrong.

Severity: Notice
Message: Undefined offset: 8
Filename: core/Auth_Controller.php
Line Number: 426
Backtrace:


RE: Community Auth : Login Error - skunkbad - 07-11-2017

Show your changed array, and how you are using Community Auth. (Show some code please)


RE: Community Auth : Login Error - Pawan - 07-11-2017

Code:
$config['levels_and_roles'] = [
    '2' => 'basic',
    '4' => 'advance',
    '8' => 'admin'
];

No other changes in Auth_Controller or any otherther.
please tell me if you need any specific file

Code:
DEBUG - 2017-07-11 15:47:21 --> Total execution time: 0.3040
DEBUG - 2017-07-11 15:48:14 --> UTF-8 Support Enabled
DEBUG - 2017-07-11 15:48:14 --> Global POST, GET and COOKIE data sanitized
DEBUG - 2017-07-11 15:48:14 --> Config file loaded: C:\wamp64\www\webaccounts\application\config/db_tables.php
DEBUG - 2017-07-11 15:48:14 --> Config file loaded: C:\wamp64\www\webaccounts\application\third_party/community_auth/config/db_tables.php
DEBUG - 2017-07-11 15:48:14 --> Config file loaded: C:\wamp64\www\webaccounts\application\config/authentication.php
DEBUG - 2017-07-11 15:48:14 --> Config file loaded: C:\wamp64\www\webaccounts\application\third_party/community_auth/config/authentication.php
DEBUG - 2017-07-11 15:48:14 --> Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.
DEBUG - 2017-07-11 15:48:14 --> Encryption: Auto-configured driver 'openssl'.
DEBUG - 2017-07-11 15:48:14 --> Session class already loaded. Second attempt ignored.
DEBUG - 2017-07-11 15:48:14 --> Tokens class already loaded. Second attempt ignored.
DEBUG - 2017-07-11 15:48:14 --> Authentication class already loaded. Second attempt ignored.
DEBUG - 2017-07-11 15:48:14 -->
string     = skunkbot
password   = Pawan6161
form_token = 7e3bb15a
token_jar  = ["7e3bb15a"]
DEBUG - 2017-07-11 15:48:14 --> Config file loaded: C:\wamp64\www\webaccounts\application\third_party/community_auth/config/examples/password_strength.php
DEBUG - 2017-07-11 15:48:14 --> Config file loaded: C:\wamp64\www\webaccounts\application\third_party/community_auth/config/form_validation/examples/login.php
ERROR - 2017-07-11 15:48:14 --> Severity: Notice --> Undefined offset: 8 C:\wamp64\www\webaccounts\application\core\Auth_Controller.php 426
DEBUG - 2017-07-11 15:48:15 --> Total execution time: 0.9615



RE: Community Auth : Login Error - skunkbad - 07-11-2017

I guess the thing I would want to know is why your log shows that you are loading two different db_tables.php and two different config/authentication.php. Also, log showing that you are loading sessions twice, tokens twice, and Authentication library twice?

My guess is that even though you think you've changed your roles array, CI is still loading the other one. Let me know.


RE: Community Auth : Login Error - Pawan - 07-11-2017

thanks, Sometime i behave like a dumb. Actually after importing Community Auth files i forgot to delete the copies which caused these problem.
Now Everything is good and smooth.