Closed abunaum closed 2 years ago
$googleService = new \Google\Service\Oauth2($google);
$data = $googleService->userinfo->get();
$email = $data->email;
$gambar = $data->picture;
$cekuser = $this->userconf->where('email', $email)->first();
if ($cekuser) {
$userupdate = [
'id' => $cekuser['id'],
'oauth_id' => $data->id,
'name' => $data->name,
'profile' => $gambar,
];
$this->userconf->save($userupdate);
} else {
$useradd = [
'email' => $email,
'username' => $email,
'oauth_id' => $data->id,
'name' => $data->name,
'profile' => $gambar,
'active' => 1
];
$this->userconf->save($useradd);
}
$newc = new \App\Models\Userconf();
$ceklagi = $newc->where('email', $email)->first();
$id = $ceklagi['id'];
$db = \Config\Database::connect();
$groupbuilder = $db->table('auth_groups_users');
$masuk = [
'group_id' => 3,
'user_id' => $id
];
$groupbuilder->insert($masuk);
//How to set status is logged_in here?
return redirect()->to(base_url('cekrole'));
Your issue's remind me of https://github.com/lonnieezell/myth-auth/projects/1#card-37568378 Maybe, @MGatner has comment about this?
Try the login
method on the authentication service:
service('authentication')->login($user, $remember);
Social logins are no longer planned for this library.
i add google login in myth auth login form, but i can't set status to logged_in after insert data to table users, how to set status user is logged_in after login with google account ? thank's