CodeIgniter Forums
Community auth not working - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forum-7.html)
+--- Forum: Addins (https://forum.codeigniter.com/forum-13.html)
+--- Thread: Community auth not working (/thread-62265.html)

Pages: 1 2


Community auth not working - rakibtg - 06-26-2015

i have installed @skunkbad's Community Auth in my CI3 site followed by the instructions.

i was able to create a dummy user by editing the user_data array that is inside the create_user method, and that creates a user in the database as well.

now once i try to login, it always shows that username/password doesnt matched!
Quote:Login Error: Invalid Username, Email Address, or Password.

Username, email address and password are all case sensitive.

Any idea Smile


RE: Community auth not working - skunkbad - 06-26-2015

Have you tried to follow the instructions for debugging?

http://community-auth.com/documentation/debugging

If you are trying to log into /examples, did you create your user with user_level 9 ?


RE: Community auth not working - rakibtg - 06-26-2015

(06-26-2015, 07:24 AM)skunkbad Wrote: Have you tried to follow the instructions for debugging?

http://community-auth.com/documentation/debugging

If you are trying to log into /examples, did you create your user with user_level 9 ?

Many Thanks for your support :=)

Here is bottomline of the log:
Quote:INFO - 2015-06-26 17:21:20 --> Form Validation Class Initialized

DEBUG - 2015-06-26 17:21:20 --> Config file loaded: E:\Installed Softwares\wamp\www\pst.dev\public\application\third_party/community_auth/config/form_validation/auth/login.php
INFO - 2015-06-26 17:21:20 --> Language file loaded: language/english/form_validation_lang.php
INFO - 2015-06-26 17:21:20 --> Model Class Initialized
DEBUG - 2015-06-26 17:21:20 --> 
 LOGIN ATTEMPT DID NOT PASS FORM VALIDATION
INFO - 2015-06-26 17:21:20 --> File loaded: E:\Installed Softwares\wamp\www\pst.dev\public\application\third_party/community_auth/views/auth/login_form.php
INFO - 2015-06-26 17:21:20 --> Final output sent to browser
DEBUG - 2015-06-26 17:21:20 --> Total execution time: 0.3090

what i am doing wrong?


RE: Community auth not working - skunkbad - 06-26-2015

(06-26-2015, 08:24 AM)rakibtg Wrote:
(06-26-2015, 07:24 AM)skunkbad Wrote: Have you tried to follow the instructions for debugging?

http://community-auth.com/documentation/debugging

If you are trying to log into /examples, did you create your user with user_level 9 ?

Many Thanks for your support :=)

Here is bottomline of the log:

Quote:INFO - 2015-06-26 17:21:20 --> Form Validation Class Initialized

DEBUG - 2015-06-26 17:21:20 --> Config file loaded: E:\Installed Softwares\wamp\www\pst.dev\public\application\third_party/community_auth/config/form_validation/auth/login.php
INFO - 2015-06-26 17:21:20 --> Language file loaded: language/english/form_validation_lang.php
INFO - 2015-06-26 17:21:20 --> Model Class Initialized
DEBUG - 2015-06-26 17:21:20 --> 
 LOGIN ATTEMPT DID NOT PASS FORM VALIDATION
INFO - 2015-06-26 17:21:20 --> File loaded: E:\Installed Softwares\wamp\www\pst.dev\public\application\third_party/community_auth/views/auth/login_form.php
INFO - 2015-06-26 17:21:20 --> Final output sent to browser
DEBUG - 2015-06-26 17:21:20 --> Total execution time: 0.3090

what i am doing wrong?

Create your user with a stronger password. See the formval_callbacks model to see how a password is checked for strength. You would normally use this callback when creating your user, bit since I am providing a over-simplified user creation, I didn't account for that. I will add a note to the installation instructions. FYI, a password like "Something1" has an uppercase letter, a number, and is long enough to pass validation. "Rrakibtg1" would also be an acceptable password.


RE: Community auth not working - rakibtg - 06-27-2015

Thanks skunkbad, yes once i change the password then it worked.
also i think we need a option to disable this feature?
again, great library! thanks for the library


RE: Community auth not working - skunkbad - 06-27-2015

(06-27-2015, 02:50 AM)rakibtg Wrote: Thanks  skunkbad, yes once i change the password then it worked.
also i think we need a option to disable this feature?
again, great library! thanks for the library

I could make this a setting, but even then the default would have to be password strength be checked, for everyone's safety.

If you want to be able to disable the password strength checking, you can modify the form validation rules in .third_party/community_auth/config/form_validation/auth/login.php. If you remove the check, you should at least replace it with a max_length[255] or something.


RE: Community auth not working - rakibtg - 06-28-2015

I think i am messing up with the library :/ i cant understand how to call the function from the controller, for example here is how i am loading the view:
Code:
$this->load->view('template/header', [
            'title' => 'Welcome',
            'auth'  => $this->is_logged_in()
        ]);
which is not working, shows error, again i tried like this because we autoload the library:

Code:
$this->load->view('template/header', [
            'title' => 'Welcome',
            'auth'  => $this->Authentication->is_logged_in()
        ]);
but all are showing "Call to undefined method ..."
please help


RE: Community auth not working - skunkbad - 06-28-2015

First, look at the Examples controller. Like the Examples controller, your controller needs to extend MY_Controller. MY_Controller, which should now be in your application/core directory needs to have been copied from the community_auth/core directory. This is part of the installation instructions.

Now that you have your controller set up to use Community Auth, consider this:


Code:
<?php
defined('BASEPATH') or exit('No direct script access allowed');

class Foo extends MY_Controller
{
   public function __construct()
   {
       parent::__construct();
   }

   // -----------------------------------------------------------------------

   public function index()
   {
       if( $this->require_role('admin') )
       {
           // Admin is logged in! No need to call is_logged_in().
           // Auth related variables have
           // been loaded in Auth_Controller. These variables are
           // available as Class properties in your controller,
           // view variables in your views, or config items anywhere.

           $this->load->view('template/header', [
               'title' => 'Welcome Admin'
           ]);
       }
   }
   
   // -----------------------------------------------------------------------

   public function bar()
   {
       // This method does not require login,
       // but we use is_logged_in to make vars available
       
       $this->is_logged_in();

       // If user is logged in, auth related variables have
       // been loaded in Auth_Controller. These variables are
       // available as Class properties in your controller,
       // view variables in your views, or config items anywhere.

       $this->load->view('template/header', [
           'title' => 'Welcome'
       ]);
   }
   
   // -----------------------------------------------------------------------
}

Take a look at the _set_user_variables() method in Auth_Controller to see the variables that are available for you to use. Also, the Community Auth documentation shares this information: http://community-auth.com/documentation/usage/authentication-variables


RE: Community auth not working - vsuri - 08-08-2015

Hi skunkbad ,
i am trying to implement the community auth in my project but i am facing issue. The jar is always coming empty when i try to login. Can you please help me so i can implement it smoothly.
I create a user admin1 but every time when i try to login it is giving following error.

Login Error: Invalid Username, Email Address, or Password.
Username, email address and password are all case sensitive.

I also checked it via make log and it is going in this code section in authentication.php library:
/**
* If a login string and password were posted, and the form token
* and flash token were not set, then we treat this as a failed login
* attempt.
*/
else if(
! is_null( $string ) &&
! is_null( $password )
)

and reason is token_jar  = [].
So i want to understand the issue what i have done wrong. Please check once and reply


RE: Community auth not working - skunkbad - 08-08-2015

(08-08-2015, 12:18 AM)vsuri Wrote: Hi skunkbad ,
i am trying to implement the community auth in my project but i am facing issue. The jar is always coming empty when i try to login. Can you please help me so i can implement it smoothly.
I create a user admin1 but every time when i try to login it is giving following error.

Login Error: Invalid Username, Email Address, or Password.
Username, email address and password are all case sensitive.

I also checked it via make log and it is going in this code section in authentication.php library:
/**
* If a login string and password were posted, and the form token
* and flash token were not set, then we treat this as a failed login
* attempt.
*/
else if(
! is_null( $string ) &&
! is_null( $password )
)

and reason is token_jar  = [].
So i want to understand the issue what i have done wrong. Please check once and reply

Does your token cookie exist? Are you using the default login form? If you have customized a form, please show some code.