From eef2093c884996c72eb42caa340d64435586827a Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Jun 2021 11:40:59 -0400 Subject: [PATCH] Add "auth" parameter to tune connect form --- README.md | 5 +++++ components/app.js | 8 +++++++- components/connect-form.js | 24 +++++++++++++++++++----- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7100e46..862d228 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,11 @@ gamja default settings can be set using a `config.json` file at the root: "url": "wss://irc.example.org", // Channel(s) to auto-join (string or array of strings). "autojoin": "#gamja", + // Controls how the password UI is presented to the user. Set to + // "mandatory" to require a password, "optional" to accept one but not + // require it, and "disabled" to never ask for a password. Defaults to + // "optional". + "auth": "optional", // Interval in seconds to send PING commands (number). Set to 0 to // disable. Enabling PINGs can have an impact on client power usage and // should only be enabled if necessary. diff --git a/components/app.js b/components/app.js index 7c90e1e..ff4f8d5 100644 --- a/components/app.js +++ b/components/app.js @@ -213,7 +213,12 @@ export default class App extends Component { } this.setState((state) => { - return { connectParams: { ...state.connectParams, ...connectParams } }; + return { + connectParams: { + ...state.connectParams, + ...connectParams, + }, + }; }); if (connectParams.autoconnect) { @@ -1203,6 +1208,7 @@ export default class App extends Component { <${ConnectForm} error=${this.state.error} params=${this.state.connectParams} + auth=${this.config.server ? this.config.server.auth : null} connecting=${connecting} onSubmit=${this.handleConnectSubmit} key=${this.state.connectParams} diff --git a/components/connect-form.js b/components/connect-form.js index 4deb947..ac89331 100644 --- a/components/connect-form.js +++ b/components/connect-form.js @@ -98,6 +98,24 @@ export default class ConnectForm extends Component { `; } + var auth = null; + if (this.props.auth !== "disabled") { + auth = html` + +

+ `; + } + return html`

Connect to IRC

@@ -108,11 +126,7 @@ export default class ConnectForm extends Component {

- -

+ ${auth}