Добавил авторизацию по типам

This commit is contained in:
Ruslan Yusupov 2019-05-12 16:15:08 +00:00
parent 4004d2f53c
commit 5f05dd0958
3 changed files with 37 additions and 13 deletions

View file

@ -5,6 +5,8 @@ var profilesList = [];
var movePoint = null; var movePoint = null;
var pingers = {}; var pingers = {};
var loginData; var loginData;
// Variable which contains all types of auth. Appending data at line 255
var authTypes = {};
function initLauncher() { function initLauncher() {
initLoginScene(); initLoginScene();
@ -186,7 +188,11 @@ function goAuth(event) {
if (login.isEmpty()) { if (login.isEmpty()) {
return; return;
} }
var auth = authOptions.getSelectionModel().getSelectedItem();
if (auth === null) {
LogHelper.info("AuthType is not selected");
return;
}
var rsaPassword = null; var rsaPassword = null;
if (!passwordField.isDisable()) { if (!passwordField.isDisable()) {
var password = passwordField.getText(); var password = passwordField.getText();
@ -202,7 +208,7 @@ function goAuth(event) {
} }
settings.login = login; settings.login = login;
doAuth(login, rsaPassword); doAuth(login, rsaPassword, authTypes[auth]);
} }
/* ======== Console ======== */ /* ======== Console ======== */
@ -239,15 +245,24 @@ function verifyLauncher(e) {
//result.list; //result.list;
//result.list[0].name; //result.list[0].name;
//result.list[0].displayName; //result.list[0].displayName;
var iter = 0;
authTypes = {};
result.list.forEach(function(auth_type, i, arr) { result.list.forEach(function(auth_type, i, arr) {
var serverAuth = new com.jfoenix.controls.JFXComboBox(); var serverAuth = new com.jfoenix.controls.JFXComboBox();
serverAuth.getStyleClass().add("authOptions"); serverAuth.getStyleClass().add("authOptions");
// add display name to items and add name with iter to variable authTypes
(function() {
authOptions.getItems().add(auth_type.displayName); authOptions.getItems().add(auth_type.displayName);
})(); authTypes[auth_type.displayName] = auth_type.name;
iter++;
}); });
var sm = authOptions.getSelectionModel().selectedIndexProperty();
// add listener to authOptions select
sm.addListener(new javafx.beans.value.ChangeListener({
changed: function (observableValue, oldSelection, newSelection) {
// get auth name from authTypes
settings.auth_type = authTypes[authOptions.getSelectionModel().getSelectedItem()];
}
}));
overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) { overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) {
settings.lastProfiles = result.profiles; settings.lastProfiles = result.profiles;
updateProfilesList(result.profiles); updateProfilesList(result.profiles);
@ -262,13 +277,14 @@ function verifyLauncher(e) {
})); }));
} }
function doAuth(login, rsaPassword) { function doAuth(login, rsaPassword, auth_type) {
processing.resetOverlay(); processing.resetOverlay();
overlay.show(processing.overlay, function (event) { overlay.show(processing.overlay, function (event) {
FunctionalBridge.getHWID.join(); FunctionalBridge.getHWID.join();
makeAuthRequest(login, rsaPassword, function (result) { makeAuthRequest(login, rsaPassword, auth_type, function (result) {
FunctionalBridge.setAuthParams(result); FunctionalBridge.setAuthParams(result);
loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions}; loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions,
auth_type: settings.auth_type};
overlay.hide(0, function () { overlay.hide(0, function () {
setCurrentScene(menuScene); setCurrentScene(menuScene);

View file

@ -124,9 +124,9 @@ function makeSetProfileRequest(profile, callback) {
startTask(task); startTask(task);
} }
function makeAuthRequest(login, rsaPassword, callback) { function makeAuthRequest(login, rsaPassword, auth_id, callback) {
var task = rsaPassword === null ? newTask(offlineAuthRequest(login)) : var task = rsaPassword === null ? newTask(offlineAuthRequest(login)) :
newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID())); newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID(), auth_id));
processing.setTaskProperties(task, callback, null, true); processing.setTaskProperties(task, callback, null, true);
task.updateMessage("Авторизация на сервере"); task.updateMessage("Авторизация на сервере");
startTask(task); startTask(task);

View file

@ -145,7 +145,7 @@ LogHelper.debug("Dir: %s", DirBridge.dir);
var cliParams = { var cliParams = {
login: null, password: null, profile: -1, autoLogin: false, login: null, password: null, profile: -1, autoLogin: false,
updatesDir: null, autoEnter: null, fullScreen: null, ram: -1, updatesDir: null, autoEnter: null, fullScreen: null, ram: -1,
offline: false, offline: false, auth: null,
init: function(params) { init: function(params) {
var named = params.getNamed(); var named = params.getNamed();
@ -180,6 +180,11 @@ var cliParams = {
if (offline !== null) { if (offline !== null) {
cliParams.offline = java.lang.Boolean.parseBoolean(offline); cliParams.offline = java.lang.Boolean.parseBoolean(offline);
} }
var auth_type = named.get("auth");
if (auth_type !== null) {
cliParams.auth = auth_type;
}
}, },
applySettings: function() { applySettings: function() {
@ -208,5 +213,8 @@ var cliParams = {
if (cliParams.offline !== null) { if (cliParams.offline !== null) {
settings.offline = cliParams.offline; settings.offline = cliParams.offline;
} }
if (cliParams.auth !== null) {
settings.auth_type = cliParams.auth;
}
} }
}; };