Add post-connect UI to login via SASL
If the server supports SASL and if we aren't logged in with any account, add a UI to authenticate via SASL. This allows users to login anonymously then login via SASL. This will also ease the draft/account-registration implementation.
This commit is contained in:
parent
24b50a332c
commit
3e2ac307f6
4 changed files with 120 additions and 3 deletions
51
components/auth-form.js
Normal file
51
components/auth-form.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
import { html, Component } from "../lib/index.js";
|
||||
|
||||
export default class NetworkForm extends Component {
|
||||
state = {
|
||||
username: "",
|
||||
password: "",
|
||||
};
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.handleChange = this.handleChange.bind(this);
|
||||
this.handleSubmit = this.handleSubmit.bind(this);
|
||||
|
||||
if (props.username) {
|
||||
this.state.username = props.username;
|
||||
}
|
||||
}
|
||||
|
||||
handleChange(event) {
|
||||
let target = event.target;
|
||||
let value = target.type == "checkbox" ? target.checked : target.value;
|
||||
this.setState({ [target.name]: value });
|
||||
}
|
||||
|
||||
handleSubmit(event) {
|
||||
event.preventDefault();
|
||||
|
||||
this.props.onSubmit(this.state.username, this.state.password);
|
||||
}
|
||||
|
||||
render() {
|
||||
return html`
|
||||
<form onChange=${this.handleChange} onSubmit=${this.handleSubmit}>
|
||||
<label>
|
||||
Username:<br/>
|
||||
<input type="username" name="username" value=${this.state.username} required/>
|
||||
</label>
|
||||
<br/><br/>
|
||||
|
||||
<label>
|
||||
Password:<br/>
|
||||
<input type="password" name="password" value=${this.state.password} required autofocus/>
|
||||
</label>
|
||||
<br/><br/>
|
||||
|
||||
<button>Login</button>
|
||||
</form>
|
||||
`;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue