Exemplo n.º 1
0
 /**
  * @param      $actionId  int El id de la acción
  * @param      $authToken string El token de seguridad
  * @param null $userPass  string La clave del usuario
  * @throws SPException
  */
 public function __construct($actionId, $authToken, $userPass = null)
 {
     if (!Auth::checkAuthToken($actionId, $authToken)) {
         throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
     }
     $this->_userId = ApiTokens::getUserIdForToken($authToken);
     $this->_actionId = $actionId;
     $this->_auth = true;
     if (!is_null($userPass)) {
         $userLogin = UserUtil::getUserLoginById($this->_userId);
         $User = new User();
         $User->setUserId($this->_userId);
         $User->setUserLogin($userLogin);
         $User->setUserPass($userPass);
         if (Auth::authUserMySQL($userLogin, $userPass) && !UserUtil::checkUserIsDisabled($userLogin) && UserPass::checkUserMPass($User) && UserPass::checkUserUpdateMPass($userLogin) && !$User->isUserChangePass()) {
             $this->_mPass = $User->getUserMPass(true);
         } else {
             throw new SPException(SPException::SP_CRITICAL, _('Acceso no permitido'));
         }
     }
     Session::setUserId($this->_userId);
 }
Exemplo n.º 2
0
            $Log->addDescription(sprintf('%s: %s', _('Usuario'), $userLogin));
            $Log->writeLog();
            SP\Response::printJSON(_('Cuenta expirada'));
        } else {
            if ($resLdap === 702) {
                $Log->addDescription('(LDAP)');
                $Log->addDescription(_('El usuario no tiene grupos asociados'));
                $Log->addDescription(sprintf('%s: %s', _('Usuario'), $userLogin));
                $Log->writeLog();
                SP\Response::printJSON(_('Usuario/Clave incorrectos'));
            } else {
                // Autentificamos por MySQL (ha fallado LDAP)
                $Log->resetDescription();
                $Log->addDescription('(MySQL)');
                // Autentificamos con la BBDD
                if (!SP\Auth::authUserMySQL($userLogin, $userPass)) {
                    $Log->addDescription(_('Login incorrecto'));
                    $Log->addDescription(sprintf('%s: %s', _('Usuario'), $userLogin));
                    $Log->writeLog();
                    SP\Response::printJSON(_('Usuario/Clave incorrectos'));
                }
            }
        }
    }
}
// Comprobar si concide el login con la autentificación del servidor web
if (!Auth::checkServerAuthUser($userLogin)) {
    $Log->addDescription(_('Login incorrecto'));
    $Log->addDescription(sprintf('%s: %s', _('Usuario'), $userLogin));
    $Log->addDescription(sprintf('%s: %s (%s)', _('Autentificación'), Auth::getServerAuthType(), Auth::getServerAuthUser()));
    $Log->writeLog();