Login through a domain

Asked

Viewed 102 times

0

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

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

I’m using the same social network function for this, example, I’m making a request for the file inside the social network, which is responsible for the login of the social network, and I’m consulting for the Domain of the chat boom, so I put the email and password and click ok, it makes the request and leads directly to the social network, only 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 in.

Well, I don’t think you’re creating a session because I’m trying to log in through Ubdomain. So I wanted to know how I do so that I can log in via chat, and I need to be redirected to 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 wait for answers, and I clear my doubts.

  • Alisson I ask you to enter a minimum or full code that addresses the problem, as is done to session for wowonder what kind of encryption?

  • Ready these codes are the codes that wowonder uses for login, I just took the javascript and put in the chat boom, and of course I modified the url

  • No one to guide?

  • There may be several factors that can create login routes within the wowonder, some require in particular that in the chat is not being called, if the wowonder was developed on some framework or in pure php in MVC there may be some controller or class that arrow some variables in Session or in the database, in which case when copying the code it does not work in another directory.

  • I imagine, I’ve been analyzing and I’m thinking about putting the chat in a folder, and not in a domain, maybe I can create a session, inside the main folder of the site

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.