06-17-2015, 01:57 AM
Hi, I am trying to implement Facebook authentication with Ion Auth. So I have the following method:
The problem is, if user will set a custom password from his account and will try to login on my website with facebook will fail. How can I do?
Code:
public function login() {
//$this->ci->load->library('ion_auth');
// null at first
$code = $this->ci->input->get('code');
// if is not set go make a facebook connection
if(!$code) {
// create a unique state
$this->ci->session->set_userdata('state', md5(uniqid(rand(), TRUE)));
redirect($this->login_url());
} else {
// check if session state is equal to the returned state
$user = $this->get_user();
if($user) {
// check if this user is already registered
if(!$this->ci->ion_auth->identity_check($user['email'])){
//$name = explode(" ", $user['first_name']);
$register = $this->ci->ion_auth->register($user['first_name'].$user['last_name'], 'facebookdoesnothavepass123^&*%', $user['email'], array('first_name' => $user['first_name'], 'last_name' => $user['last_name']));
$login = $this->ci->ion_auth->login($user['email'], 'facebookdoesnothavepass123^&*%', 1, TRUE);
if($login) {
$user = $this->ci->ion_auth->user()->row();
redirect('/account/profile/'.$user->username, 'refresh');
}
} else {
$login = $this->ci->ion_auth->login($user['email'], 'facebookdoesnothavepass123^&*%', 1, TRUE);
if($login) {
$user = $this->ci->ion_auth->user()->row();
redirect('/account/profile/'.$user->username, 'refresh');
}
//print_r($login);
}
return true;
}
else {
return false;
}
}
}
The problem is, if user will set a custom password from his account and will try to login on my website with facebook will fail. How can I do?