Login through a subdomain

0

I have a problem to solve. I have a social network, and I have a chat from the chat boom, the social network is wowonder.

I am integrating the login system of the social network into the chat boom, but when I try to login, through the boom chat screen that is in a subdomain, the following happens:

I'm using the same social network function for this, for example, I'm making a request for the file within the social network, which is responsible for the social network login, and I'm querying for the chat boom subdomain, so I put the email and password and I click ok, it makes the request and takes it directly to the social network, but it is not logged in, it goes to the login screen of the social network, which in turn is the same index, should be logged. / p>

Well, I do not think you're creating a session because I'm trying to log in to the subdomain. So I wanted to know how I can make it possible for me to log in through the chat, and I need to be redirected to the social network?

Codes:

<script>
var working = false;
var $this = $('#login');
var $state = $this.find('button > .state');
var login_button_text = '<i class="fa fa-sign-in"></i> Login';
$(function () {
    $('#login').ajaxForm({
        url: 'https://ghender.com/requests.php?f=login',
        beforeSend: function () {
            working = true;
            $this.addClass('loading');
            $state.html('autenticação');
        },
        success: function (data) {
            console.log(data);
            if (data.status == 200 || data.status == 600) {
                $this.addClass('ok');
                $state.html('Bem vindo de volta!');
                setTimeout(function () {
                   window.location.href = "https://ghender.com";
                    //window.location.href = data.location;
                }, 1000);
            } else {
                var errors = data.errors.join("<br>");
                $state.html(login_button_text);
                $this.removeClass('ok loading', function () {
                    $state.html(errors);
                });
            }
            working = false;
        }
    });
    $('#login input').on('click', function (e) {
        $state.html(login_button_text);
    });
});

if ($f == 'login') {
$data_ = array();
$phone = 0;
if (isset($_POST['username']) && isset($_POST['password'])) {
    $username = Wo_Secure($_POST['username']);
    $password = Wo_Secure($_POST['password']);
    $result = Wo_Login($username, $password);
    if ($result === false) {
        $errors[] = $error_icon . $wo['lang']['incorrect_username_or_password_label'];
    } else if (Wo_UserInactive($_POST['username']) === true) {
        $errors[] = $error_icon . $wo['lang']['account_disbaled_contanct_admin_label'];
    } else if (Wo_UserActive($_POST['username']) === false) {
        $_SESSION['code_id'] = Wo_UserIdForLogin($username);
        $data_ = array(
            'status' => 600,
            'location' => Wo_SeoLink('index.php?link1=user-activation')
        );
        $phone = 1;
    }
    if (empty($errors) && $phone == 0) {
        $userid = Wo_UserIdForLogin($username);
        $ip = Wo_Secure(get_ip_address());
        $update = mysqli_query($sqlConnect, "UPDATE " . T_USERS . " SET 'ip_address' = '{$ip}' WHERE 'user_id' = '{$userid}'");
        $session = Wo_CreateLoginSession(Wo_UserIdForLogin($username));
        $_SESSION['user_id'] = $session;
        setcookie(
                "user_id", $session, time() + (10 * 365 * 24 * 60 * 60)
        );
        $data = array(
            'status' => 200
        );
        if (!empty($_POST['last_url'])) {
            $data['location'] = $_POST['last_url'];
        } else {
            $data['location'] = $wo['config']['site_url'];
        }
    }
}
header("Content-type: application/json");
if (!empty($errors)) {
    echo json_encode(array(
        'errors' => $errors
    ));
} else if (!empty($data_)) {
    echo json_encode($data_);
} else {
    echo json_encode($data);
}
exit();
}

I am waiting for answers, and I take the doubts.

    
asked by anonymous 23.10.2017 / 14:39

0 answers