Revert "better way to auth, prepping for client use"

This reverts commit a1d4bd8d3b.
This commit is contained in:
Pierce 2018-11-29 21:38:47 -05:00
parent a1d4bd8d3b
commit 9362fe25df
3 changed files with 22 additions and 192 deletions

View file

@ -3,20 +3,8 @@ const uuid = require('uuid/v1');
const api_url = "https://authserver.mojang.com";
function getAuth(username, password) {
function login(username, password) {
return new Promise(resolve => {
if(!password) {
const user = {
access_token: uuid(),
client_token: uuid(),
uuid: uuid(),
name: username,
user_object: JSON.stringify({})
};
resolve(user);
}
const requestObject = {
url: api_url + "/authenticate",
json: {
@ -49,6 +37,23 @@ function getAuth(username, password) {
});
}
module.exports = async function(username, password) {
return await getAuth(username, password);
function offline(username) {
let user = {
access_token: uuid(),
client_token: uuid(),
uuid: uuid(),
name: username,
user_object: JSON.stringify({})
};
return user;
}
module.exports = async function(_offline, username, password) {
if(_offline) {
return offline(username);
}
return await login(username, password);
};

View file

@ -9,6 +9,8 @@ const shelljs = require('shelljs');
module.exports = async function (options) {
if (!fs.existsSync(options.root)) fs.mkdirSync(options.root);
options.authorization = await ygg(options.login.offline, options.login.username, options.login.password);
const versionFile = await handler.getVersion(options.version.number);
const directory = path.join(options.root, 'versions', options.version.number);
options.directory = directory;