<?php

require __DIR__ . '/../common.php';
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\e4658d476fc6000297da2bf923569e5c6\A28e1fe41bbbb5c3237b6939f8431d48a;
use Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\f43aac94c61399fab94959a50d7a8abb5\ec34b9ec19989f74d49bed0bf40f0d51;
if (!\Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\e4658d476fc6000297da2bf923569e5c6\A28e1fe41bbbb5c3237b6939f8431d48a::D7da717e52c608d70fb3f48607f5636ea()->V041d80d62cca44e2567f80cd78f963cd('auth_url', '')) {
    echo '{"status":"ERROR","results":false,"error":"Auth disabled"}';
    exit;
}
if (empty($_REQUEST['login']) || empty($_REQUEST['password'])) {
    echo '{"status":"ERROR","results":false,"error":"Login and password required"}';
    exit;
}
\sleep(1);
$login = $_REQUEST['login'];
$password = $_REQUEST['password'];
$mac = isset($_REQUEST['mac']) ? $_REQUEST['mac'] : '';
$profileObject = \Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\e4658d476fc6000297da2bf923569e5c6\A28e1fe41bbbb5c3237b6939f8431d48a::D7da717e52c608d70fb3f48607f5636ea()->D81cce0e15d5b12280f36f561f12ba50f()->get(\Ministra\Lib\bd5c9022e9a9029209e5fd05775ea272\f43aac94c61399fab94959a50d7a8abb5\ec34b9ec19989f74d49bed0bf40f0d51::class);
$possibleUser = $profileObject->I0e601b2e3a01f6fdd2960998e42bea74($login);
if (\md5(\md5($password) . $possibleUser['id']) === $possibleUser['password']) {
    $user = $possibleUser;
}
if (empty($user)) {
    echo \error('User not exist or login-password mismatch');
} else {
    if ($mac) {
        $profileObject->db43ad847e14def15d65b90b2b77341a(['mac' => '', 'device_id' => '', 'device_id2' => '', 'access_token' => ''], ['mac' => $mac]);
    }
    $profileObject->db43ad847e14def15d65b90b2b77341a(['mac' => $mac], ['id' => $user['id']]);
    echo '{"status":"OK","results":true}';
}
