Dont send default server password to the client
This commit is contained in:
parent
1a7360a573
commit
2e8418516a
File diff suppressed because one or more lines are too long
@ -9,7 +9,8 @@ import { select } from '../actions/tab';
|
|||||||
@pure
|
@pure
|
||||||
class Connect extends Component {
|
class Connect extends Component {
|
||||||
state = {
|
state = {
|
||||||
showOptionals: false
|
showOptionals: false,
|
||||||
|
passwordTouched: false
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSubmit = (e) => {
|
handleSubmit = (e) => {
|
||||||
@ -27,7 +28,10 @@ class Connect extends Component {
|
|||||||
if (this.state.showOptionals) {
|
if (this.state.showOptionals) {
|
||||||
opts.realname = e.target.realname.value.trim();
|
opts.realname = e.target.realname.value.trim();
|
||||||
opts.username = e.target.username.value.trim();
|
opts.username = e.target.username.value.trim();
|
||||||
opts.password = e.target.password.value.trim();
|
|
||||||
|
if (this.state.passwordTouched) {
|
||||||
|
opts.password = e.target.password.value.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (address.indexOf('.') > 0 && nick) {
|
if (address.indexOf('.') > 0 && nick) {
|
||||||
@ -50,6 +54,10 @@ class Connect extends Component {
|
|||||||
this.setState({ showOptionals: !this.state.showOptionals });
|
this.setState({ showOptionals: !this.state.showOptionals });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handlePasswordChange = () => {
|
||||||
|
this.setState({ passwordTouched: true });
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const defaults = window.__ENV__.defaults;
|
const defaults = window.__ENV__.defaults;
|
||||||
let optionals = null;
|
let optionals = null;
|
||||||
@ -62,7 +70,8 @@ class Connect extends Component {
|
|||||||
name="password"
|
name="password"
|
||||||
type="password"
|
type="password"
|
||||||
placeholder="Password"
|
placeholder="Password"
|
||||||
defaultValue={defaults.password}
|
defaultValue={defaults.password ? ' ' : null}
|
||||||
|
onChange={this.handlePasswordChange}
|
||||||
/>
|
/>
|
||||||
<input name="realname" type="text" placeholder="Realname" />
|
<input name="realname" type="text" placeholder="Realname" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,7 +13,7 @@ type connectDefaults struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
Channels []string `json:"channels"`
|
Channels []string `json:"channels"`
|
||||||
Password string `json:"password"`
|
Password bool `json:"password"`
|
||||||
SSL bool `json:"ssl"`
|
SSL bool `json:"ssl"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ func getIndexData(r *http.Request, session *Session) *indexData {
|
|||||||
Name: viper.GetString("defaults.name"),
|
Name: viper.GetString("defaults.name"),
|
||||||
Address: viper.GetString("defaults.address"),
|
Address: viper.GetString("defaults.address"),
|
||||||
Channels: viper.GetStringSlice("defaults.channels"),
|
Channels: viper.GetStringSlice("defaults.channels"),
|
||||||
Password: viper.GetString("defaults.password"),
|
Password: viper.GetString("defaults.password") != "",
|
||||||
SSL: viper.GetBool("defaults.ssl"),
|
SSL: viper.GetBool("defaults.ssl"),
|
||||||
},
|
},
|
||||||
Servers: servers,
|
Servers: servers,
|
||||||
|
@ -97,6 +97,12 @@ func (h *wsHandler) connect(b []byte) {
|
|||||||
i.Password = data.Password
|
i.Password = data.Password
|
||||||
i.Realname = data.Realname
|
i.Realname = data.Realname
|
||||||
|
|
||||||
|
if data.Password == "" && viper.GetString("defaults.password") != "" {
|
||||||
|
i.Password = viper.GetString("defaults.password")
|
||||||
|
} else {
|
||||||
|
i.Password = data.Password
|
||||||
|
}
|
||||||
|
|
||||||
if cert := h.session.user.GetCertificate(); cert != nil {
|
if cert := h.session.user.GetCertificate(); cert != nil {
|
||||||
i.TLSConfig = &tls.Config{
|
i.TLSConfig = &tls.Config{
|
||||||
Certificates: []tls.Certificate{*cert},
|
Certificates: []tls.Certificate{*cert},
|
||||||
|
Loading…
Reference in New Issue
Block a user