mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-19 14:33:04 +03:00
Добавил авторизацию по типам
This commit is contained in:
parent
4004d2f53c
commit
5f05dd0958
3 changed files with 37 additions and 13 deletions
|
@ -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();
|
||||
|
@ -186,7 +188,11 @@ 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();
|
||||
|
@ -202,7 +208,7 @@ function goAuth(event) {
|
|||
}
|
||||
|
||||
settings.login = login;
|
||||
doAuth(login, rsaPassword);
|
||||
doAuth(login, rsaPassword, authTypes[auth]);
|
||||
}
|
||||
|
||||
/* ======== Console ======== */
|
||||
|
@ -239,15 +245,24 @@ function verifyLauncher(e) {
|
|||
//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");
|
||||
|
||||
(function() {
|
||||
authOptions.getItems().add(auth_type.displayName);
|
||||
})();
|
||||
// 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);
|
||||
|
@ -262,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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue