mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
feat: added admin password and admin modal
This commit is contained in:
@@ -136,6 +136,7 @@ class DCSInstance {
|
||||
blueCommanderPassword = "";
|
||||
redCommanderPassword = "";
|
||||
gameMasterPasswordHash = "";
|
||||
adminPassword = "";
|
||||
installed = false;
|
||||
error = false;
|
||||
webserverOnline = false;
|
||||
@@ -149,6 +150,7 @@ class DCSInstance {
|
||||
gameMasterPasswordEdited = false;
|
||||
blueCommanderPasswordEdited = false;
|
||||
redCommanderPasswordEdited = false;
|
||||
adminPasswordEdited = false;
|
||||
autoconnectWhenLocal = false;
|
||||
SRSPort = 5002;
|
||||
|
||||
@@ -196,6 +198,7 @@ class DCSInstance {
|
||||
this.gameMasterPasswordEdited = false;
|
||||
this.blueCommanderPasswordEdited = false;
|
||||
this.redCommanderPasswordEdited = false;
|
||||
this.adminPasswordEdited = false;
|
||||
|
||||
} catch (err) {
|
||||
showErrorPopup(`<div class='main-message'>A critical error has occurred while reading your Olympus configuration file. </div><div class='sub-message'> Please manually reinstall Olympus in ${this.folder} using either the installation Wizard or the Expert view. </div>`)
|
||||
@@ -277,7 +280,7 @@ class DCSInstance {
|
||||
|
||||
/** Set Blue Commander password
|
||||
*
|
||||
* @param {String} newAddress The new Blue Commander password to set
|
||||
* @param {String} newPassword The new Blue Commander password to set
|
||||
*/
|
||||
setBlueCommanderPassword(newPassword) {
|
||||
this.blueCommanderPassword = newPassword;
|
||||
@@ -286,13 +289,22 @@ class DCSInstance {
|
||||
|
||||
/** Set Red Commander password
|
||||
*
|
||||
* @param {String} newAddress The new Red Commander password to set
|
||||
* @param {String} newPassword The new Red Commander password to set
|
||||
*/
|
||||
setRedCommanderPassword(newPassword) {
|
||||
this.redCommanderPassword = newPassword;
|
||||
this.redCommanderPasswordEdited = true;
|
||||
}
|
||||
|
||||
/** Set Admin password
|
||||
*
|
||||
* @param {String} newPassword The new Admin password to set
|
||||
*/
|
||||
setAdminPassword(newPassword) {
|
||||
this.adminPassword = newPassword;
|
||||
this.adminPasswordEdited = true;
|
||||
}
|
||||
|
||||
/** Checks if any password has been edited by the user
|
||||
*
|
||||
* @returns true if any password was edited
|
||||
@@ -306,7 +318,10 @@ class DCSInstance {
|
||||
* @returns true if all the password have been set
|
||||
*/
|
||||
arePasswordsSet() {
|
||||
return !(getManager().getActiveInstance().gameMasterPassword === '' || getManager().getActiveInstance().blueCommanderPassword === '' || getManager().getActiveInstance().redCommanderPassword === '');
|
||||
if (getManager().getActiveInstance().installationType === "singleplayer")
|
||||
return !(getManager().getActiveInstance().gameMasterPassword === '' || getManager().getActiveInstance().blueCommanderPassword === '' || getManager().getActiveInstance().redCommanderPassword === '');
|
||||
else
|
||||
return !(getManager().getActiveInstance().gameMasterPassword === '' || getManager().getActiveInstance().blueCommanderPassword === '' || getManager().getActiveInstance().redCommanderPassword === '' || getManager().getActiveInstance().adminPassword === '');
|
||||
}
|
||||
|
||||
/** Checks if all the passwords are different
|
||||
|
||||
@@ -181,6 +181,9 @@ async function applyConfiguration(folder, instance) {
|
||||
if (instance.redCommanderPassword !== "")
|
||||
config["authentication"]["redCommanderPassword"] = sha256(instance.redCommanderPassword);
|
||||
|
||||
if (instance.adminPassword !== "")
|
||||
config["authentication"]["adminPassword"] = sha256(instance.adminPassword);
|
||||
|
||||
await fsp.writeFile(path.join(folder, "Config", "olympus.json"), JSON.stringify(config, null, 4));
|
||||
logger.log(`Config succesfully applied in ${folder}`)
|
||||
} else {
|
||||
|
||||
@@ -475,7 +475,7 @@ class Manager {
|
||||
}
|
||||
|
||||
async onGameMasterPasswordChanged(value) {
|
||||
for (let input of this.activePage.getElement().querySelectorAll("input[type='password']")) {
|
||||
for (let input of this.activePage.getElement().querySelectorAll("input[type='password'].unique")) {
|
||||
input.placeholder = "";
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ class Manager {
|
||||
}
|
||||
|
||||
async onBlueCommanderPasswordChanged(value) {
|
||||
for (let input of this.activePage.getElement().querySelectorAll("input[type='password']")) {
|
||||
for (let input of this.activePage.getElement().querySelectorAll("input[type='password'].unique")) {
|
||||
input.placeholder = "";
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ class Manager {
|
||||
}
|
||||
|
||||
async onRedCommanderPasswordChanged(value) {
|
||||
for (let input of this.activePage.getElement().querySelectorAll("input[type='password']")) {
|
||||
for (let input of this.activePage.getElement().querySelectorAll("input[type='password'].unique")) {
|
||||
input.placeholder = "";
|
||||
}
|
||||
|
||||
@@ -507,6 +507,13 @@ class Manager {
|
||||
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${this.getLogLocation()} for more info. </div>`);
|
||||
}
|
||||
|
||||
async onAdminPasswordChanged(value) {
|
||||
if (this.getActiveInstance())
|
||||
this.getActiveInstance().setAdminPassword(value);
|
||||
else
|
||||
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${this.getLogLocation()} for more info. </div>`);
|
||||
}
|
||||
|
||||
/* When the frontend port input value is changed */
|
||||
async onFrontendPortChanged(value) {
|
||||
this.setPort('frontend', Number(value));
|
||||
|
||||
Reference in New Issue
Block a user