Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lockNetwork breaks login screen (fields are missing) #4735

Open
Kufat opened this issue May 14, 2023 · 4 comments
Open

lockNetwork breaks login screen (fields are missing) #4735

Kufat opened this issue May 14, 2023 · 4 comments
Labels
Type: Bug Issues that report and PRs that solve any defects that cause unexpected behaviors.

Comments

@Kufat
Copy link
Contributor

Kufat commented May 14, 2023

  • Node version: 12.22.9
  • Browser version: Chrome 113.0.5672.93
  • Device, operating system: Generic cobbled-together Windows 10 22H2 desktop
  • The Lounge version: 4.3.1, problem also seems to exist in 4.4.0

When lockNetwork is true, NetworkForm.vue hides some fields/options that would be expected to be shown. (Commands, the option for SASL External, possibly others.) I believe the problem is that https://github.com/thelounge/thelounge/blob/master/server/server.ts#L871 strips those out of the defaults object but I'm unable to test it to be certain.

If I'm right, adding "tls" and "uuid" to the fields that are passed through should ameliorate the issue. (Perhaps instead of only allowing certain fields, only fields that must be disallowed should be stripped?)

@Kufat Kufat added the Type: Bug Issues that report and PRs that solve any defects that cause unexpected behaviors. label May 14, 2023
@Kufat
Copy link
Contributor Author

Kufat commented May 18, 2023

In addition, editing a locked network will remove the name. Steps:

  1. Open https://demo.thelounge.chat/
  2. Connect
  3. Right click on the network name, edit network
  4. Make no changes and hit "save changes." Network name becomes blank.

If The Lounge is running in private mode, this is a pain to fix.

Problem seems to be that edit() in network.ts doesn't handle the case where the args only have a subset of the network data.

@Kufat
Copy link
Contributor Author

Kufat commented May 18, 2023

I've apparently fixed this locally but will test a bit before I provide a PR. This is my first time working with TypeScript, Vue, etc. and one of my first times working with Node, so I'm not super confident in my ability to fix bugs without side effects. ;p

@MaxLeiter
Copy link
Member

Looking forward to your PR, @Kufat! thank you for the bug report and potential fix!

@Kufat
Copy link
Contributor Author

Kufat commented May 27, 2023

@MaxLeiter Part of the problem is that the 'args' passed to edit() in network.ts doesn't always contain all args.
It's a straightforward fix but I don't know how to do the check idiomatically.

Example: ('sasl' might or might not be omitted from 'args' under some circumstances)

// Current
this.sasl = String(args.sasl || "");
// Problem: sasl field is cleared if absent from object
// Bad fix:
this.sasl = String(args.sasl || this.sasl || "");
// Problem: Can't clear sasl even if you want to

// Options:
// Option 1
if( 'sasl' in args ) {
  this.sasl= args.sasl;
}
 
// Option 2
this.sasl = 'sasl' in args ? args.sasl : this.sasl;
 
// Option 3
'sasl' in args && ( this.sasl = args.sasl );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issues that report and PRs that solve any defects that cause unexpected behaviors.
Projects
None yet
Development

No branches or pull requests

2 participants