From 95bcd09e9b19447f97eebf54713bc3d94465d119 Mon Sep 17 00:00:00 2001 From: Ruslan Yusupov Date: Sun, 12 May 2019 16:33:48 +0000 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8E=20=D0=BF=D0=BE=20=D1=82=D0=B8=D0=BF=D0=B0?= =?UTF-8?q?=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Launcher/runtime/dialog/dialog.js | 91 +++++++++++-------- .../dialog/overlay/processing/processing.js | 4 +- .../dialog/overlay/settings/settings.js | 10 +- 3 files changed, 62 insertions(+), 43 deletions(-) diff --git a/Launcher/runtime/dialog/dialog.js b/Launcher/runtime/dialog/dialog.js index 77cf4281..76ac3222 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(); @@ -59,12 +61,12 @@ function initLoginScene() { savePasswordBox = pane.lookup("#rememberchb"); savePasswordBox.setSelected(settings.login === null || settings.rsaPassword !== null); + authOptions = pane.lookup("#authOptions"); + var link = pane.lookup("#link"); link.setText(config.linkText); link.setOnAction(function(event) app.getHostServices().showDocument(config.linkURL.toURI())); - authOptions = pane.lookup("#authOptions"); - pane.lookup("#goAuth").setOnAction(goAuth); } @@ -186,32 +188,30 @@ function goAuth(event) { if (login.isEmpty()) { return; } + var auth = authOptions.getSelectionModel().getSelectedItem(); + if (auth === null) { + LogHelper.info("AuthType is not selected"); + return; + } + var rsaPassword = null; + if (!passwordField.isDisable()) { + var password = passwordField.getText(); + if (password !== null && !password.isEmpty()) { + rsaPassword = settingsOverlay.setPassword(password); + } else if (settings.rsaPassword !== null) { + rsaPassword = settings.rsaPassword; + } else { + return; + } - // Get auth - /* var auth = authOptions.getSelectionModel().getSelectedItem(); - if (auth === null) { - return; // No auth selected - }*/ + settings.rsaPassword = savePasswordBox.isSelected() ? rsaPassword : null; + } - var rsaPassword = null; - if (!passwordField.isDisable()) { - var password = passwordField.getText(); - if (password !== null && !password.isEmpty()) { - rsaPassword = settingsOverlay.setPassword(password); - } else if (settings.rsaPassword !== null) { - rsaPassword = settings.rsaPassword; - } else { - return; - } + settings.login = login; + doAuth(login, rsaPassword, authTypes[auth]); +} - settings.rsaPassword = savePasswordBox.isSelected() ? rsaPassword : null; - } - - settings.login = login; - doAuth(/*auth, */login, rsaPassword); - } - - /* ======== Console ======== */ +/* ======== Console ======== */ function goConsole(event) { setConsoleCurrentScene(consoleScene); } @@ -242,17 +242,27 @@ 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); - })(); - - }); + //result.list; + //result.list[0].name; + //result.list[0].displayName; + 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_type = authTypes[authOptions.getSelectionModel().getSelectedItem()]; + } + })); overlay.swap(0, processing.overlay, function(event) makeProfilesRequest(function(result) { settings.lastProfiles = result.profiles; updateProfilesList(result.profiles); @@ -267,13 +277,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_type}; overlay.hide(0, function () { setCurrentScene(menuScene); @@ -460,7 +471,7 @@ var serverHolder = { set: function(btn){ pingServer(btn); - serverLabel.setText(profilesList[btn]); + serverLabel.setText("СЕРВЕР " + profilesList[btn]); serverDescription.setText(profilesList[btn].info); btn.setSelected(true); btn.setDisable(true); diff --git a/Launcher/runtime/dialog/overlay/processing/processing.js b/Launcher/runtime/dialog/overlay/processing/processing.js index f14a6638..059abf24 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_id, callback) { 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); task.updateMessage("Авторизация на сервере"); startTask(task); diff --git a/Launcher/runtime/dialog/overlay/settings/settings.js b/Launcher/runtime/dialog/overlay/settings/settings.js index 590dea8b..f9ccba30 100644 --- a/Launcher/runtime/dialog/overlay/settings/settings.js +++ b/Launcher/runtime/dialog/overlay/settings/settings.js @@ -145,7 +145,7 @@ LogHelper.debug("Dir: %s", DirBridge.dir); var cliParams = { login: null, password: null, profile: -1, autoLogin: false, updatesDir: null, autoEnter: null, fullScreen: null, ram: -1, - offline: false, + offline: false, auth: null, init: function(params) { var named = params.getNamed(); @@ -180,6 +180,11 @@ var cliParams = { if (offline !== null) { cliParams.offline = java.lang.Boolean.parseBoolean(offline); } + + var auth_type = named.get("auth"); + if (auth_type !== null) { + cliParams.auth = auth_type; + } }, applySettings: function() { @@ -208,5 +213,8 @@ var cliParams = { if (cliParams.offline !== null) { settings.offline = cliParams.offline; } + if (cliParams.auth !== null) { + settings.auth_type = cliParams.auth; + } } };