mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-19 14:33:04 +03:00
Доработал авторизацию по типам
This commit is contained in:
parent
a8f8073f8c
commit
95bcd09e9b
3 changed files with 62 additions and 43 deletions
|
@ -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();
|
||||||
|
@ -59,12 +61,12 @@ function initLoginScene() {
|
||||||
savePasswordBox = pane.lookup("#rememberchb");
|
savePasswordBox = pane.lookup("#rememberchb");
|
||||||
savePasswordBox.setSelected(settings.login === null || settings.rsaPassword !== null);
|
savePasswordBox.setSelected(settings.login === null || settings.rsaPassword !== null);
|
||||||
|
|
||||||
|
authOptions = pane.lookup("#authOptions");
|
||||||
|
|
||||||
var link = pane.lookup("#link");
|
var link = pane.lookup("#link");
|
||||||
link.setText(config.linkText);
|
link.setText(config.linkText);
|
||||||
link.setOnAction(function(event) app.getHostServices().showDocument(config.linkURL.toURI()));
|
link.setOnAction(function(event) app.getHostServices().showDocument(config.linkURL.toURI()));
|
||||||
|
|
||||||
authOptions = pane.lookup("#authOptions");
|
|
||||||
|
|
||||||
pane.lookup("#goAuth").setOnAction(goAuth);
|
pane.lookup("#goAuth").setOnAction(goAuth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,13 +188,11 @@ function goAuth(event) {
|
||||||
if (login.isEmpty()) {
|
if (login.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var auth = authOptions.getSelectionModel().getSelectedItem();
|
||||||
// Get auth
|
|
||||||
/* var auth = authOptions.getSelectionModel().getSelectedItem();
|
|
||||||
if (auth === null) {
|
if (auth === null) {
|
||||||
return; // No auth selected
|
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();
|
||||||
|
@ -208,7 +208,7 @@ function goAuth(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.login = login;
|
settings.login = login;
|
||||||
doAuth(/*auth, */login, rsaPassword);
|
doAuth(login, rsaPassword, authTypes[auth]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ======== Console ======== */
|
/* ======== Console ======== */
|
||||||
|
@ -245,14 +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) {
|
||||||
(function() {
|
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);
|
authOptions.getItems().add(auth_type.displayName);
|
||||||
//var sm = authOptions.getSelectionModel();
|
authTypes[auth_type.displayName] = auth_type.name;
|
||||||
//sm.selectedIndexProperty()["addListener(javafx.beans.value.ChangeListener)"](settings.auth = i);
|
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);
|
||||||
|
@ -267,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);
|
||||||
|
@ -460,7 +471,7 @@ var serverHolder = {
|
||||||
|
|
||||||
set: function(btn){
|
set: function(btn){
|
||||||
pingServer(btn);
|
pingServer(btn);
|
||||||
serverLabel.setText(profilesList[btn]);
|
serverLabel.setText("СЕРВЕР " + profilesList[btn]);
|
||||||
serverDescription.setText(profilesList[btn].info);
|
serverDescription.setText(profilesList[btn].info);
|
||||||
btn.setSelected(true);
|
btn.setSelected(true);
|
||||||
btn.setDisable(true);
|
btn.setDisable(true);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue