public function finishAuthentication(AuthenticationType $type) { $db = Loader::db(); $u = new User(); if ($u->getUserID() == 1 && $type->getAuthenticationTypeHandle() != 'concrete') { $u->logout(); throw new \Exception(t('You can only identify as the admin user using the concrete login.')); } $ui = UserInfo::getByID($u->getUserID()); $aks = UserAttributeKey::getRegistrationList(); $unfilled = array_values(array_filter($aks, function ($ak) use($ui) { return $ak->isAttributeKeyRequiredOnRegister() && !is_object($ui->getAttributeValueObject($ak)); })); if (count($unfilled)) { $u->logout(false); if (!$this->error) { $this->on_start(); } $this->set('required_attributes', $unfilled); $this->set('u', $u); Session::set('uRequiredAttributeUser', $u->getUserID()); Session::set('uRequiredAttributeUserAuthenticationType', $type->getAuthenticationTypeHandle()); $this->view(); echo $this->getViewObject()->render(); exit; } $u->setLastAuthType($type); $ue = new \Concrete\Core\User\Event\User($u); Events::dispatch('on_user_login', $ue); $this->chooseRedirect(); }
/** * @param AuthenticationType $type Required * * @throws \Exception */ public function finishAuthentication($type = null) { if (!$type || !$type instanceof AuthenticationType) { return $this->view(); } $u = new User(); $config = $this->app->make('config'); if ($config->get('concrete.i18n.choose_language_login')) { $userLocale = $this->post('USER_LOCALE'); if (is_string($userLocale) && $userLocale !== '') { if ($userLocale !== 'en_US') { $availableLocales = Localization::getAvailableInterfaceLanguages(); if (!in_array($userLocale, $availableLocales)) { $userLocale = ''; } } if ($userLocale !== '') { if (Localization::activeLocale() !== $userLocale) { Localization::changeLocale($userLocale); } $u->setUserDefaultLanguage($userLocale); } } } $ui = UserInfo::getByID($u->getUserID()); $aks = UserAttributeKey::getRegistrationList(); $unfilled = array_values(array_filter($aks, function ($ak) use($ui) { return $ak->isAttributeKeyRequiredOnRegister() && !is_object($ui->getAttributeValueObject($ak)); })); if (count($unfilled)) { $u->logout(false); if (!$this->error) { $this->on_start(); } $this->set('required_attributes', $unfilled); $this->set('u', $u); $session = $this->app->make('session'); $session->set('uRequiredAttributeUser', $u->getUserID()); $session->set('uRequiredAttributeUserAuthenticationType', $type->getAuthenticationTypeHandle()); $this->view(); return $this->getViewObject()->render(); } $u->setLastAuthType($type); $ue = new \Concrete\Core\User\Event\User($u); $this->app->make('director')->dispatch('on_user_login', $ue); return $this->chooseRedirect(); }
public function getAuthenticationTypeHandle() { return parent::getAuthenticationTypeHandle(); }