mirror of
https://github.com/thelounge/thelounge.git
synced 2024-05-01 22:22:54 +02:00
Disable connecting to the same network multiple times if lockNetwork is enabled
This commit is contained in:
parent
6221f96ff2
commit
85f83a7c9a
|
@ -34,7 +34,10 @@ export default defineComponent({
|
|||
};
|
||||
|
||||
onMounted(() => {
|
||||
if (store.state.serverConfiguration?.lockNetwork) {
|
||||
if (
|
||||
store.state.serverConfiguration?.lockNetwork &&
|
||||
store.state.serverConfiguration?.allowMultipleSameHostConnections
|
||||
) {
|
||||
if (store.state.networks.length > 0) {
|
||||
disabled.value = true;
|
||||
disabledReason.value = "You have already connected and cannot connect again.";
|
||||
|
|
|
@ -285,6 +285,15 @@ module.exports = {
|
|||
// This value is set to `false` by default.
|
||||
lockNetwork: false,
|
||||
|
||||
// ### `sameHostLockedNetworkConnections`
|
||||
//
|
||||
// When set to `true`, users will be able to connect to the configured
|
||||
// network multiple times. This can be useful if you connect to
|
||||
// a bouncer like ZNC. Requires `lockNetwork` to be set to `true`.
|
||||
//
|
||||
// This value is set to `false` by default.
|
||||
allowMultipleSameHostConnections: false,
|
||||
|
||||
// ## User management
|
||||
|
||||
// ### `messageStorage`
|
||||
|
|
|
@ -96,6 +96,7 @@ export type ConfigType = {
|
|||
leaveMessage: string;
|
||||
defaults: Defaults;
|
||||
lockNetwork: boolean;
|
||||
allowMultipleSameHostConnections: boolean;
|
||||
messageStorage: string[];
|
||||
useHexIp: boolean;
|
||||
webirc?: WebIRC;
|
||||
|
|
|
@ -48,7 +48,12 @@ type IndexTemplateConfiguration = ServerConfiguration & {
|
|||
|
||||
export type ClientConfiguration = Pick<
|
||||
ConfigType,
|
||||
"public" | "lockNetwork" | "useHexIp" | "prefetch" | "defaults"
|
||||
| "public"
|
||||
| "lockNetwork"
|
||||
| "useHexIp"
|
||||
| "prefetch"
|
||||
| "defaults"
|
||||
| "allowMultipleSameHostConnections"
|
||||
> & {
|
||||
fileUpload: boolean;
|
||||
ldapEnabled: boolean;
|
||||
|
@ -478,7 +483,7 @@ function initializeClient(
|
|||
});
|
||||
|
||||
socket.on("network:new", (data) => {
|
||||
if (Config.values.lockNetwork) {
|
||||
if (Config.values.lockNetwork && Config.values.allowMultipleSameHostConnections) {
|
||||
if (client.networks.length > 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -869,6 +874,8 @@ function getClientConfiguration(): ClientConfiguration {
|
|||
"lockNetwork",
|
||||
"useHexIp",
|
||||
"prefetch",
|
||||
"allowMultipleSameHostConnections",
|
||||
// TODO: remove this type cast
|
||||
]) as ClientConfiguration;
|
||||
|
||||
config.fileUpload = Config.values.fileUpload.enable;
|
||||
|
|
|
@ -131,6 +131,7 @@ describe("Server", function () {
|
|||
expect(data.defaultTheme).to.equal("default");
|
||||
expect(data.themes).to.be.an("array");
|
||||
expect(data.lockNetwork).to.equal(false);
|
||||
|
||||
expect(data.useHexIp).to.equal(false);
|
||||
|
||||
done();
|
||||
|
|
Loading…
Reference in a new issue