diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 77cf4281..483e49e6 100644 --- a/Launcher/runtime/dialog/dialog.js +++ b/Launcher/runtime/dialog/dialog.js @@ -5,6 +5,8 @@ var profilesList = []; var movePoint = null; var pingers = {}; var loginData; +// Variable which contains all types of auth. Appending data at line 255 +var authTypes = {}; function initLauncher() { initLoginScene(); @@ -188,12 +190,16 @@ function goAuth(event) { } // Get auth - /* var auth = authOptions.getSelectionModel().getSelectedItem(); - if (auth === null) { - return; // No auth selected - }*/ + var auth = authOptions.getSelectionModel().getSelectedItem(); + if (auth === null) { + return; // No auth selected + } var rsaPassword = null; + var auth = authOptions.getSelectionModel().getSelectedItem(); + if (auth === null) { + return; + } if (!passwordField.isDisable()) { var password = passwordField.getText(); if (password !== null && !password.isEmpty()) { @@ -208,7 +214,7 @@ function goAuth(event) { } settings.login = login; - doAuth(/*auth, */login, rsaPassword); + doAuth(/*auth, */login, rsaPassword, authTypes[auth]); } /* ======== Console ======== */ @@ -242,17 +248,24 @@ function verifyLauncher(e) { initOffline(); } overlay.swap(0, processing.overlay, function(event) makeAuthAvailabilityRequest(function(result) { - //result.list; - //result.list[0].name; - //result.list[0].displayName; - result.list.forEach(function(auth_type, i, arr) { - (function() { - authOptions.getItems().add(auth_type.displayName); - //var sm = authOptions.getSelectionModel(); - //sm.selectedIndexProperty()["addListener(javafx.beans.value.ChangeListener)"](settings.auth = i); - })(); - - }); + var iter = 0; + authTypes = {}; + result.list.forEach(function(auth_type, i, arr) { + var serverAuth = new com.jfoenix.controls.JFXComboBox(); + serverAuth.getStyleClass().add("authOptions"); + // add display name to items and add name with iter to variable authTypes + 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 = authTypes[authOptions.getSelectionModel().getSelectedItem()]; + } + })); overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) { settings.lastProfiles = result.profiles; updateProfilesList(result.profiles); @@ -267,13 +280,14 @@ function verifyLauncher(e) { })); } -function doAuth(login, rsaPassword) { +function doAuth(login, rsaPassword, auth_type) { processing.resetOverlay(); overlay.show(processing.overlay, function (event) { FunctionalBridge.getHWID.join(); - makeAuthRequest(login, rsaPassword, function (result) { + makeAuthRequest(login, rsaPassword, auth_type, function (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}; overlay.hide(0, function () { setCurrentScene(menuScene); diff --git a/Launcher/runtime/dialog/overlay/processing/processing.js b/Launcher/runtime/dialog/overlay/processing/processing.js index f14a6638..568cc2ee 100644 --- a/Launcher/runtime/dialog/overlay/processing/processing.js +++ b/Launcher/runtime/dialog/overlay/processing/processing.js @@ -124,9 +124,9 @@ function makeSetProfileRequest(profile, callback) { startTask(task); } -function makeAuthRequest(login, rsaPassword, callback) { +function makeAuthRequest(login, rsaPassword, auth_type, callback) { var task = rsaPassword === null ? newTask(offlineAuthRequest(login)) : - newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID())); + newRequestTask(new AuthRequest(login, rsaPassword, FunctionalBridge.getHWID(), auth_type)); processing.setTaskProperties(task, callback, null, true); task.updateMessage("Авторизация на сервере"); startTask(task);