{"size": 1142, "ext": "js", "max_stars_repo_path": "src/javascript/binary/base/login.js", "max_stars_repo_name": "ashkanx/binary-mt", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/javascript/binary/base/login.js", "max_issues_repo_name": "ashkanx/binary-mt", "max_issues_repo_issues_event_min_datetime": "2016-09-22T07:23:29.000Z", "max_issues_repo_issues_event_max_datetime": "2017-02-01T01:39:44.000Z", "max_forks_repo_path": "src/javascript/binary/base/login.js", "max_forks_repo_name": "ashkanx/binary-mt", "max_forks_repo_forks_event_min_datetime": "2016-09-13T02:10:40.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-11T23:11:01.000Z"}
{"max_stars_count": null, "max_issues_count": 3, "max_forks_count": 10, "avg_line_length": 34.6060606061, "max_line_length": 128, "alphanum_fraction": 0.5665499124}
var Login = (function() {
    "use strict";

    var redirect_to_login = function() {
        if (!page.client.is_logged_in && !is_login_pages()) {
            try {
                sessionStorage.setItem('redirect_url', window.location.href);
            } catch(e) {
                alert('The website needs features which are not enabled on private mode browsing. Please use normal mode.');
            }
            window.location.href = this.login_url();
        }
    };

    var login_url = function() {
        var server_url = localStorage.getItem('config.server_url');
        return ((server_url && /qa/.test(server_url)) ?
            'https://www.' + server_url.split('.')[1] + '.com/oauth2/authorize?app_id=' + getAppId() + '&l=' + page.language() :
            'https://oauth.binary.com/oauth2/authorize?app_id=' + getAppId() + '&l=' + page.language()
        );
    };

    var is_login_pages = function() {
        return /logged_inws|oauth2/.test(document.URL);
    };

    return {
        redirect_to_login: redirect_to_login,
        is_login_pages   : is_login_pages,
        login_url        : login_url,
    };
}());
