You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i add google login to my web but i dont know how to login to system after get user data from google callback ..
here my controller.
`public function googlecallback()
{
$socialite = new SocialiteManager(config('Ci4gen')->social);
$code = $this->request->getVar('code');
$user = $socialite->create('google')->userFromCode($code);
$userId = $this->loginOrRegister($user);
return redirect()->to('admin/dashboard');
}
protected function loginOrRegister($user)
{
$userModel = new \App\Models\UserModel();
$userData = $userModel->where('email', $user['email'])->first();
if ($userData == null) {
$data = [
'name' => $user['name'],
'email' => $user['email'],
'provider_id' => $user['id'],
'avatar' => $user['avatar'],
'username' => $user['username'],
'active' => 1,
'created_at' => date('Y-m-d H:i:s')
];
$db = \Config\Database::connect();
$builder = $db->table('users');
$builder = $builder->insert($data);
// login here its return error invalid model .
//use Myth\Auth\Authentication\AuthenticationBase as BaseAuth;
$authact = new BaseAuth(config('Auth'));
$authact->loginByID($db->insertID());
}else{
// login programmatically here by $user variable
}
}`
The text was updated successfully, but these errors were encountered:
tamapratamaongit
changed the title
#question How to login programmatically from controller without password ?
#question How to login programmatically from controller without password or use loginById Function from AuthenticationBase ?
Jun 15, 2021
tamapratamaongit
changed the title
#question How to login programmatically from controller without password or use loginById Function from AuthenticationBase ?
Question : How to login programmatically from controller without password or use loginById Function from AuthenticationBase ?
Jun 15, 2021
i add google login to my web but i dont know how to login to system after get user data from google callback ..
here my controller.
`public function googlecallback()
{
The text was updated successfully, but these errors were encountered: