protected function attemptAuthentication() { $user = parent::attemptAuthentication(); $userInfo = \UserInfo::getByID($user->getUserID()); $extractor = $this->getExtractor(); $roles = $extractor->getExtra('roles'); // sync groups with roles if (is_array($roles)) { $groupIds = array(); foreach ($roles as $role) { $roleApplicationCode = $role['role_application']['application_code']; if ($roleApplicationCode == \Config::get('auth.worldskills.roles_application_code')) { $roleName = $role['name']; // check for entity role and append entity name if (isset($role['ws_entity'])) { $roleName = $roleName . ' - ' . $role['ws_entity']['name']['text']; } // check if group exists $group = \Group::getByName($roleName); if (!is_object($group)) { // add missing groups $group = \Group::add($roleName, ''); } $groupIds[] = $group->getGroupID(); } } // remove duplicate groups $groupIds = array_unique($groupIds); // update groups of user $userInfo->updateGroups($groupIds); } // login user again to make sure groups are reloaded return \User::loginByUserID($user->getUserID()); }
public function getExtractor() { try { return parent::getExtractor(); } catch (\Exception $e) { dd($e); } }
public function completeAuthentication(User $u) { $ui = \UserInfo::getByID($u->getUserID()); if (!$ui->hasAvatar()) { try { $image = \Image::open($this->getExtractor()->getImageURL()); $ui->updateUserAvatar($image); } catch (\Imagine\Exception\InvalidArgumentException $e) { \Log::addNotice("Unable to fetch user images in Google Authentication Type, is allow_url_fopen disabled?"); } catch (\Exception $e) { } } return parent::completeAuthentication($u); }