/** * Handle user logged in. * * @param \Illuminate\Contracts\Auth\Authenticatable $user * * @return bool|null */ public function handle(Authenticatable $user) { $social = $this->session->get('authentication.social.oauth'); if (is_null($social)) { return; } $model = User::where('provider', '=', $social['provider'])->where('uid', '=', $social['user']->getId())->first(); if (is_null($model)) { return; } $model->setAttribute('user_id', $user->getAuthIdentifier()); $model->save(); return true; }
/** * Get user unique identifier or return null. * * @param \Orchestra\OneAuth\User $model * * @return mixed|null */ protected function getAuthenticatedUser(Eloquent $model) { return $model->getAttribute('user_id'); }