Combine displayNetwork
into lockNetwork
This commit is contained in:
parent
8a281bacd8
commit
6ee71779d1
@ -11,12 +11,10 @@
|
||||
</template>
|
||||
<template v-else>
|
||||
Connect
|
||||
<template v-if="!config.displayNetwork && config.lockNetwork">
|
||||
to {{ defaults.name }}
|
||||
</template>
|
||||
<template v-if="config.lockNetwork">to {{ defaults.name }}</template>
|
||||
</template>
|
||||
</h1>
|
||||
<template v-if="config.displayNetwork">
|
||||
<template v-if="!config.lockNetwork">
|
||||
<h2>Network settings</h2>
|
||||
<div class="connect-row">
|
||||
<label for="connect:name">Name</label>
|
||||
@ -39,7 +37,6 @@
|
||||
aria-label="Server address"
|
||||
maxlength="255"
|
||||
required
|
||||
:disabled="config.lockNetwork ? true : false"
|
||||
/>
|
||||
<span id="connect:portseparator">:</span>
|
||||
<input
|
||||
@ -52,7 +49,6 @@
|
||||
name="port"
|
||||
:value="defaults.port"
|
||||
aria-label="Server port"
|
||||
:disabled="config.lockNetwork ? true : false"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -81,9 +77,7 @@
|
||||
type="checkbox"
|
||||
name="tls"
|
||||
:checked="defaults.tls ? true : false"
|
||||
:disabled="
|
||||
config.lockNetwork || defaults.hasSTSPolicy ? true : false
|
||||
"
|
||||
:disabled="defaults.hasSTSPolicy ? true : false"
|
||||
@change="onSecureChanged"
|
||||
/>
|
||||
Use secure connection (TLS)
|
||||
@ -99,7 +93,6 @@
|
||||
type="checkbox"
|
||||
name="rejectUnauthorized"
|
||||
:checked="defaults.rejectUnauthorized ? true : false"
|
||||
:disabled="config.lockNetwork ? true : false"
|
||||
/>
|
||||
Only allow trusted certificates
|
||||
</label>
|
||||
@ -164,7 +157,7 @@
|
||||
</template>
|
||||
|
||||
<template v-if="$store.state.serverConfiguration.public">
|
||||
<template v-if="!config.displayNetwork">
|
||||
<template v-if="config.lockNetwork">
|
||||
<div class="connect-row">
|
||||
<label></label>
|
||||
<div class="input-wrap">
|
||||
|
@ -59,16 +59,11 @@ export default {
|
||||
// When the network is locked, URL overrides should not affect disabled fields
|
||||
if (
|
||||
this.$store.state.serverConfiguration.lockNetwork &&
|
||||
["host", "port", "tls", "rejectUnauthorized"].includes(key)
|
||||
["name", "host", "port", "tls", "rejectUnauthorized"].includes(key)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// When the network is not displayed, its name in the UI is not customizable
|
||||
if (!this.$store.state.serverConfiguration.displayNetwork && key === "name") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key === "join") {
|
||||
value = value
|
||||
.split(",")
|
||||
|
@ -238,25 +238,11 @@ module.exports = {
|
||||
join: "#thelounge",
|
||||
},
|
||||
|
||||
// ### `displayNetwork`
|
||||
//
|
||||
// When set to `false`, network fields will not be shown in the "Connect"
|
||||
// window.
|
||||
//
|
||||
// Note that even though users cannot access and set these fields, they can
|
||||
// still connect to other networks using the `/connect` command. See the
|
||||
// `lockNetwork` setting to restrict users from connecting to other networks.
|
||||
//
|
||||
// This value is set to `true` by default.
|
||||
displayNetwork: true,
|
||||
|
||||
// ### `lockNetwork`
|
||||
//
|
||||
// When set to `true`, users will not be able to modify host, port and TLS
|
||||
// settings and will be limited to the configured network.
|
||||
//
|
||||
// It is often useful to use it with `displayNetwork` when setting The
|
||||
// Lounge as a public web client for a specific IRC network.
|
||||
// These fields will also be hidden from the UI.
|
||||
//
|
||||
// This value is set to `false` by default.
|
||||
lockNetwork: false,
|
||||
|
@ -227,7 +227,7 @@ Client.prototype.connect = function (args, isStartup = false) {
|
||||
const network = new Network({
|
||||
uuid: args.uuid,
|
||||
name: String(
|
||||
args.name || (Helper.config.displayNetwork ? "" : Helper.config.defaults.name) || ""
|
||||
args.name || (Helper.config.lockNetwork ? Helper.config.defaults.name : "") || ""
|
||||
),
|
||||
host: String(args.host || ""),
|
||||
port: parseInt(args.port, 10),
|
||||
|
@ -125,16 +125,6 @@ function setHome(newPath) {
|
||||
mergeConfig(this.config, userConfig);
|
||||
}
|
||||
|
||||
if (!this.config.displayNetwork && !this.config.lockNetwork) {
|
||||
this.config.lockNetwork = true;
|
||||
|
||||
log.warn(
|
||||
`${colors.bold("displayNetwork")} and ${colors.bold(
|
||||
"lockNetwork"
|
||||
)} are false, setting ${colors.bold("lockNetwork")} to true.`
|
||||
);
|
||||
}
|
||||
|
||||
if (this.config.fileUpload.baseUrl) {
|
||||
try {
|
||||
new URL("test/file.png", this.config.fileUpload.baseUrl);
|
||||
|
@ -120,6 +120,7 @@ Network.prototype.validate = function (client) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.name = Helper.config.defaults.name;
|
||||
this.host = Helper.config.defaults.host;
|
||||
this.port = Helper.config.defaults.port;
|
||||
this.tls = Helper.config.defaults.tls;
|
||||
@ -436,7 +437,7 @@ Network.prototype.exportForEdit = function () {
|
||||
"commands",
|
||||
];
|
||||
|
||||
if (Helper.config.displayNetwork) {
|
||||
if (!Helper.config.lockNetwork) {
|
||||
fieldsToReturn.push("host");
|
||||
fieldsToReturn.push("port");
|
||||
fieldsToReturn.push("tls");
|
||||
|
@ -706,18 +706,12 @@ function initializeClient(socket, client, token, lastMessage, openChannel) {
|
||||
}
|
||||
|
||||
function getClientConfiguration() {
|
||||
const config = _.pick(Helper.config, [
|
||||
"public",
|
||||
"lockNetwork",
|
||||
"displayNetwork",
|
||||
"useHexIp",
|
||||
"prefetch",
|
||||
]);
|
||||
const config = _.pick(Helper.config, ["public", "lockNetwork", "useHexIp", "prefetch"]);
|
||||
|
||||
config.fileUpload = Helper.config.fileUpload.enable;
|
||||
config.ldapEnabled = Helper.config.ldap.enable;
|
||||
|
||||
if (config.displayNetwork) {
|
||||
if (!config.lockNetwork) {
|
||||
config.defaults = _.clone(Helper.config.defaults);
|
||||
} else {
|
||||
// Only send defaults that are visible on the client
|
||||
|
@ -113,7 +113,6 @@ describe("Server", function () {
|
||||
expect(data.defaultTheme).to.equal("default");
|
||||
expect(data.themes).to.be.an("array");
|
||||
expect(data.lockNetwork).to.equal(false);
|
||||
expect(data.displayNetwork).to.equal(true);
|
||||
expect(data.useHexIp).to.equal(false);
|
||||
|
||||
done();
|
||||
|
Loading…
Reference in New Issue
Block a user