Example #1
0
            $Log->addDescription(_('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(_('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(_('Usuario') . ": " . $userLogin);
                    $Log->writeLog();
                    SP\Response::printJSON(_('Usuario/Clave incorrectos'));
                }
            }
        }
    }
}
// Comprobar si el usuario está deshabilitado
if (UserUtil::checkUserIsDisabled($userLogin)) {
    $Log->addDescription(_('Usuario deshabilitado'));
    $Log->addDescription(_('Usuario') . ": " . $userLogin);
    $Log->writeLog();
    SP\Response::printJSON(_('Usuario deshabilitado'));
Example #2
0
require_once APP_ROOT . DIRECTORY_SEPARATOR . 'inc' . DIRECTORY_SEPARATOR . 'Base.php';
SP\Request::checkReferer('POST');
$sk = SP\Request::analyze('sk', false);
if (!$sk || !SessionUtil::checkSessionKey($sk)) {
    SP\Response::printJSON(_('CONSULTA INVÁLIDA'));
}
$userLogin = SP\Request::analyze('login');
$userEmail = SP\Request::analyze('email');
$userPass = SP\Request::analyzeEncrypted('pass');
$userPassR = SP\Request::analyzeEncrypted('passR');
$hash = SP\Request::analyze('hash');
$time = SP\Request::analyze('time');
$message['action'] = _('Recuperación de Clave');
if ($userLogin && $userEmail) {
    $log = new \SP\Log(_('Recuperación de Clave'));
    if (SP\Auth::mailPassRecover($userLogin, $userEmail)) {
        $log->addDescription(SP\Html::strongText(_('Solicitado para') . ': ') . ' ' . $userLogin . ' (' . $userEmail . ')');
        SP\Response::printJSON(_('Solicitud enviada') . ';;' . _('En breve recibirá un correo para completar la solicitud.'), 0, 'goLogin();');
    } else {
        $log->addDescription('ERROR');
        $log->addDescription(SP\Html::strongText(_('Solicitado para') . ': ') . ' ' . $userLogin . ' (' . $userEmail . ')');
        SP\Response::printJSON(_('No se ha podido realizar la solicitud. Consulte con el administrador.'));
    }
    $log->writeLog();
    SP\Email::sendEmail($log);
} elseif ($userPass && $userPassR && $userPass === $userPassR) {
    $userId = UserPassRecover::checkHashPassRecover($hash);
    if ($userId) {
        if (UserPass::updateUserPass($userId, $userPass) && UserPassRecover::updateHashPassRecover($hash)) {
            \SP\Log::writeNewLogAndEmail(_('Modificar Clave Usuario'), SP\Html::strongText(_('Login') . ': ') . UserUtil::getUserLoginById($userId));
            SP\Response::printJSON(_('Clave actualizada'), 0, 'goLogin();');