Merge pull request #3071 from matrix-org/t3chguy/authentication_password_field
Switch ugly password boxes to Field or styled input
This commit is contained in:
commit
9591e6b0d3
4 changed files with 35 additions and 27 deletions
|
@ -56,3 +56,7 @@ limitations under the License.
|
||||||
.mx_InteractiveAuthEntryComponents_termsPolicy {
|
.mx_InteractiveAuthEntryComponents_termsPolicy {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_InteractiveAuthEntryComponents_passwordSection {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
|
@ -21,3 +21,7 @@ limitations under the License.
|
||||||
.mx_DeactivateAccountDialog .mx_DeactivateAccountDialog_input_section {
|
.mx_DeactivateAccountDialog .mx_DeactivateAccountDialog_input_section {
|
||||||
margin-top: 60px;
|
margin-top: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mx_DeactivateAccountDialog .mx_DeactivateAccountDialog_input_section .mx_Field {
|
||||||
|
width: 300px;
|
||||||
|
}
|
||||||
|
|
|
@ -81,16 +81,10 @@ export const PasswordAuthEntry = React.createClass({
|
||||||
|
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
passwordValid: false,
|
password: "",
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
focus: function() {
|
|
||||||
if (this.refs.passwordField) {
|
|
||||||
this.refs.passwordField.focus();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_onSubmit: function(e) {
|
_onSubmit: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.props.busy) return;
|
if (this.props.busy) return;
|
||||||
|
@ -98,23 +92,21 @@ export const PasswordAuthEntry = React.createClass({
|
||||||
this.props.submitAuthDict({
|
this.props.submitAuthDict({
|
||||||
type: PasswordAuthEntry.LOGIN_TYPE,
|
type: PasswordAuthEntry.LOGIN_TYPE,
|
||||||
user: this.props.matrixClient.credentials.userId,
|
user: this.props.matrixClient.credentials.userId,
|
||||||
password: this.refs.passwordField.value,
|
password: this.state.password,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_onPasswordFieldChange: function(ev) {
|
_onPasswordFieldChange: function(ev) {
|
||||||
// enable the submit button iff the password is non-empty
|
// enable the submit button iff the password is non-empty
|
||||||
this.setState({
|
this.setState({
|
||||||
passwordValid: Boolean(this.refs.passwordField.value),
|
password: ev.target.value,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
let passwordBoxClass = null;
|
const passwordBoxClass = classnames({
|
||||||
|
"error": this.props.errorText,
|
||||||
if (this.props.errorText) {
|
});
|
||||||
passwordBoxClass = 'error';
|
|
||||||
}
|
|
||||||
|
|
||||||
let submitButtonOrSpinner;
|
let submitButtonOrSpinner;
|
||||||
if (this.props.busy) {
|
if (this.props.busy) {
|
||||||
|
@ -124,7 +116,7 @@ export const PasswordAuthEntry = React.createClass({
|
||||||
submitButtonOrSpinner = (
|
submitButtonOrSpinner = (
|
||||||
<input type="submit"
|
<input type="submit"
|
||||||
className="mx_Dialog_primary"
|
className="mx_Dialog_primary"
|
||||||
disabled={!this.state.passwordValid}
|
disabled={!this.state.password}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -138,17 +130,21 @@ export const PasswordAuthEntry = React.createClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Field = sdk.getComponent('elements.Field');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<p>{ _t("To continue, please enter your password.") }</p>
|
<p>{ _t("To continue, please enter your password.") }</p>
|
||||||
<form onSubmit={this._onSubmit}>
|
<form onSubmit={this._onSubmit} className="mx_InteractiveAuthEntryComponents_passwordSection">
|
||||||
<label htmlFor="passwordField">{ _t("Password:") }</label>
|
<Field
|
||||||
<input
|
id="mx_InteractiveAuthEntryComponents_password"
|
||||||
name="passwordField"
|
|
||||||
ref="passwordField"
|
|
||||||
className={passwordBoxClass}
|
className={passwordBoxClass}
|
||||||
onChange={this._onPasswordFieldChange}
|
|
||||||
type="password"
|
type="password"
|
||||||
|
name="passwordField"
|
||||||
|
label={_t('Password')}
|
||||||
|
autoFocus={true}
|
||||||
|
value={this.state.password}
|
||||||
|
onChange={this._onPasswordFieldChange}
|
||||||
/>
|
/>
|
||||||
<div className="mx_button_row">
|
<div className="mx_button_row">
|
||||||
{ submitButtonOrSpinner }
|
{ submitButtonOrSpinner }
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default class DeactivateAccountDialog extends React.Component {
|
||||||
this._onEraseFieldChange = this._onEraseFieldChange.bind(this);
|
this._onEraseFieldChange = this._onEraseFieldChange.bind(this);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
confirmButtonEnabled: false,
|
password: "",
|
||||||
busy: false,
|
busy: false,
|
||||||
shouldErase: false,
|
shouldErase: false,
|
||||||
errStr: null,
|
errStr: null,
|
||||||
|
@ -45,7 +45,7 @@ export default class DeactivateAccountDialog extends React.Component {
|
||||||
|
|
||||||
_onPasswordFieldChange(ev) {
|
_onPasswordFieldChange(ev) {
|
||||||
this.setState({
|
this.setState({
|
||||||
confirmButtonEnabled: Boolean(ev.target.value),
|
password: ev.target.value,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ export default class DeactivateAccountDialog extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const okLabel = this.state.busy ? <Loader /> : _t('Deactivate Account');
|
const okLabel = this.state.busy ? <Loader /> : _t('Deactivate Account');
|
||||||
const okEnabled = this.state.confirmButtonEnabled && !this.state.busy;
|
const okEnabled = this.state.password && !this.state.busy;
|
||||||
|
|
||||||
let cancelButton = null;
|
let cancelButton = null;
|
||||||
if (!this.state.busy) {
|
if (!this.state.busy) {
|
||||||
|
@ -113,6 +113,8 @@ export default class DeactivateAccountDialog extends React.Component {
|
||||||
</button>;
|
</button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Field = sdk.getComponent('elements.Field');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseDialog className="mx_DeactivateAccountDialog"
|
<BaseDialog className="mx_DeactivateAccountDialog"
|
||||||
onFinished={this.props.onFinished}
|
onFinished={this.props.onFinished}
|
||||||
|
@ -167,10 +169,12 @@ export default class DeactivateAccountDialog extends React.Component {
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>{ _t("To continue, please enter your password:") }</p>
|
<p>{ _t("To continue, please enter your password:") }</p>
|
||||||
<input
|
<Field
|
||||||
|
id="mx_DeactivateAccountDialog_password"
|
||||||
type="password"
|
type="password"
|
||||||
placeholder={_t("password")}
|
label={_t('Password')}
|
||||||
onChange={this._onPasswordFieldChange}
|
onChange={this._onPasswordFieldChange}
|
||||||
|
value={this.state.password}
|
||||||
ref={(e) => {this._passwordField = e;}}
|
ref={(e) => {this._passwordField = e;}}
|
||||||
className={passwordBoxClass}
|
className={passwordBoxClass}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue