Skip to content

Instantly share code, notes, and snippets.

@sentanos
Created March 7, 2017 01:26
Show Gist options
  • Save sentanos/09e7cad77c62fc71b0b5b37d08d58d1e to your computer and use it in GitHub Desktop.
Save sentanos/09e7cad77c62fc71b0b5b37d08d58d1e to your computer and use it in GitHub Desktop.
Alternate login API
// Includes
var http = require('./http.js').func;
var options = require('../options.js');
var settings = require('../../settings.json');
var clearSession = require('./clearSession.js').func;
// Args
exports.required = ['username', 'password'];
exports.optional = ['jar'];
// Define
exports.func = function (args) {
var jar = args.jar || options.jar;
var username = args.username;
var password = args.password;
clearSession({jar: jar});
var url = '//www.roblox.com/newlogin';
var post = {
'username': username,
'password': password
};
var httpOpt = {
url: url,
options: {
method: 'POST',
json: post,
resolveWithFullResponse: true,
jar: jar
}
};
return http(httpOpt)
.then(function (res) {
var body = res.body;
if (res.statusCode === 302) {
if (settings.session_only) {
var cookies = res.headers['set-cookie']; // If the user is already logged in a new cookie will not be returned.
if (cookies) {
var session = cookies.toString().match(/\.ROBLOSECURITY=(.*?);/)[1];
jar.session = session;
}
}
} else {
throw new Error(body);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment