Search code examples
phpcodeigniterauthenticationion-auth

ion auth, login function have no result


I'm new to codeigniter and ion_auth. I'm trying to use login function as guide explain Guide .

This is my code:

$input=$this->input->post(LOGIN_ID,true);
$user_data=json_decode($input, TRUE);
$result=$this->ion_auth->login($user_data['nickname'], $user_data['password']);
return $result;

When I print $result I get void result, so I looked in the file libraries / ion_auth and I had not found the function login. I don't know the library, so I tried to create the function in ion_auth library

public function login($identity, $password, $remember){
    return $this->ion_auth_model->login($identity, $password, $remember);
}

But result is the same, have anyone any ideas?

I saw that $result is always false, so i opened the database and the same password had different values for different users, so i think there is an error in registration

    $input=$this->input->post(REGISTRATION_INPUT,true);
    $registration_data=json_decode($input, TRUE);
    $username=$registration_data['nickname'];
    $password=$registration_data['password'];
    $email=$password=$registration_data['email'];
           $additional_data=array('first_name'=>$registration_data['name'],'last_name'=>$registration_data['surname']);
    $result=$this->ion_auth->register($username, $password, $email, $additional_data) ;

With var_dump($registration_data) all values are correct

Thanks for your patience


Solution

  • I solved, there were troubles with json, now i take data with post and all works. $username=$this->input->post('nickname',true); $password=$this->input->post('password',true); $result=$this->ion_auth->login($username,$password,true);