/** * Obtener la pestaña de seguridad */ public function getSecurityTab() { $this->setAction(self::ACTION_USR_PREFERENCES_SECURITY); $this->view->addTemplate('security'); $twoFa = new Auth2FA($this->_userId, Session::getUserLogin()); if (!$this->_userPrefs->isUse2Fa()) { $this->view->assign('qrCode', $twoFa->getUserQRCode()); } $this->view->assign('userId', $this->_userId); $this->view->assign('chk2FAEnabled', $this->_userPrefs->isUse2Fa()); $this->view->append('tabs', array('title' => _('Seguridad'))); $this->view->assign('tabIndex', $this->getTabIndex(), 'security'); $this->view->assign('actionId', $this->getAction(), 'security'); }
/** * Comprobar si el usuario está logado. * * @returns bool */ public static function isLoggedIn() { if (Session::getUserLogin() && Session::get2FApassed()) { return true; } return false; }
/** * Obtener los datos para la mostrar la barra de sesión */ private function getSessionBar() { $this->view->addTemplate('sessionbar'); $this->view->assign('adminApp', Session::getUserIsAdminApp() ? '<span title="' . _('Admin Aplicación') . '">(A+)</span>' : ''); $this->view->assign('userId', Session::getUserId()); $this->view->assign('userLogin', strtoupper(Session::getUserLogin())); $this->view->assign('userName', Session::getUserName() ? Session::getUserName() : strtoupper($this->view->userLogin)); $this->view->assign('userGroup', Session::getUserGroupName()); $this->view->assign('showPassIcon', !Session::getUserIsLdap()); }
$UserPrefs->setSortViews($sortViews); $UserPrefs->setTopNavbar($topNavbar); $UserPrefs->setOptionalActions($optionalActions); if (!$UserPrefs->updatePreferences()) { SP\Response::printJSON(_('Error al actualizar preferencias')); } // Forzar la detección del lenguaje tras actualizar SP\Language::setLanguage(true); SP\Themes::setTheme(true); // Actualizar las preferencias en la sesión y recargar la página SP\Session::setUserPreferences($UserPrefs); SP\Util::reload(); SP\Response::printJSON(_('Preferencias actualizadas'), 0, $doActionOnClose); } else { if ($actionId === SP\Controller\ActionsInterface::ACTION_USR_PREFERENCES_SECURITY) { if (SP\Util::demoIsEnabled() && \SP\Session::getUserLogin() === 'demo') { SP\Response::printJSON(_('Ey, esto es una DEMO!!')); } // Variables POST del formulario $twoFaEnabled = SP\Request::analyze('security_2faenabled', 0, false, 1); $pin = SP\Request::analyze('security_pin', 0); $userLogin = UserUtil::getUserLoginById($itemId); $twoFa = new \SP\Auth\Auth2FA($itemId, $userLogin); if (!$twoFa->verifyKey($pin)) { SP\Response::printJSON(_('Código incorrecto')); } // No se instancia la clase ya que es necesario guardar los atributos ya guardados $UserPrefs = \SP\UserPreferences::getPreferences($itemId); $UserPrefs->setId($itemId); $UserPrefs->setUse2Fa(\SP\Util::boolval($twoFaEnabled)); if (!$UserPrefs->updatePreferences()) {