Remove "Current Password" input if mx_pass exists
If the user is PWLU, do not show "Current Password" field in ChangePassword and when setting a new password, use the cached password.
This commit is contained in:
parent
5151264f60
commit
8725ef3863
4 changed files with 37 additions and 16 deletions
|
@ -216,6 +216,7 @@ export default React.createClass({
|
||||||
enableLabs={this.props.config.enableLabs}
|
enableLabs={this.props.config.enableLabs}
|
||||||
referralBaseUrl={this.props.config.referralBaseUrl}
|
referralBaseUrl={this.props.config.referralBaseUrl}
|
||||||
teamToken={this.props.teamToken}
|
teamToken={this.props.teamToken}
|
||||||
|
cachedPassword={this.props.cachedPassword}
|
||||||
/>;
|
/>;
|
||||||
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>;
|
if (!this.props.collapse_rhs) right_panel = <RightPanel opacity={this.props.sideOpacity}/>;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -590,6 +590,12 @@ module.exports = React.createClass({
|
||||||
payload.releaseNotes
|
payload.releaseNotes
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case 'password_changed':
|
||||||
|
this.setState({
|
||||||
|
userHasGeneratedPassword: false,
|
||||||
|
});
|
||||||
|
localStorage.removeItem("mx_pass");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1176,7 +1182,8 @@ module.exports = React.createClass({
|
||||||
onUserSettingsClose={this.onUserSettingsClose}
|
onUserSettingsClose={this.onUserSettingsClose}
|
||||||
onRegistered={this.onRegistered}
|
onRegistered={this.onRegistered}
|
||||||
teamToken={this._teamToken}
|
teamToken={this._teamToken}
|
||||||
userHasGeneratedPassword={this.state.userHasGeneratedPassword}
|
cachedPassword={this.state.userHasGeneratedPassword ?
|
||||||
|
localStorage.getItem('mx_pass') : null}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
{...this.state}
|
{...this.state}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -139,6 +139,9 @@ module.exports = React.createClass({
|
||||||
// Team token for the referral link. If falsy, the referral section will
|
// Team token for the referral link. If falsy, the referral section will
|
||||||
// not appear
|
// not appear
|
||||||
teamToken: React.PropTypes.string,
|
teamToken: React.PropTypes.string,
|
||||||
|
|
||||||
|
// the user is a PWLU (/w password stashed in localStorage 'mx_pass')
|
||||||
|
cachedPassword: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -331,6 +334,7 @@ module.exports = React.createClass({
|
||||||
receive push notifications on other devices until you
|
receive push notifications on other devices until you
|
||||||
log back in to them.`,
|
log back in to them.`,
|
||||||
});
|
});
|
||||||
|
dis.dispatch({action: 'password_changed'});
|
||||||
},
|
},
|
||||||
|
|
||||||
onUpgradeClicked: function() {
|
onUpgradeClicked: function() {
|
||||||
|
@ -894,6 +898,7 @@ module.exports = React.createClass({
|
||||||
rowLabelClassName="mx_UserSettings_profileLabelCell"
|
rowLabelClassName="mx_UserSettings_profileLabelCell"
|
||||||
rowInputClassName="mx_UserSettings_profileInputCell"
|
rowInputClassName="mx_UserSettings_profileInputCell"
|
||||||
buttonClassName="mx_UserSettings_button mx_UserSettings_changePasswordButton"
|
buttonClassName="mx_UserSettings_button mx_UserSettings_changePasswordButton"
|
||||||
|
cachedPassword={this.props.cachedPassword}
|
||||||
onError={this.onPasswordChangeError}
|
onError={this.onPasswordChangeError}
|
||||||
onFinished={this.onPasswordChanged} />
|
onFinished={this.onPasswordChanged} />
|
||||||
);
|
);
|
||||||
|
|
|
@ -31,7 +31,10 @@ module.exports = React.createClass({
|
||||||
rowClassName: React.PropTypes.string,
|
rowClassName: React.PropTypes.string,
|
||||||
rowLabelClassName: React.PropTypes.string,
|
rowLabelClassName: React.PropTypes.string,
|
||||||
rowInputClassName: React.PropTypes.string,
|
rowInputClassName: React.PropTypes.string,
|
||||||
buttonClassName: React.PropTypes.string
|
buttonClassName: React.PropTypes.string,
|
||||||
|
|
||||||
|
// user is a PWLU (/w password stashed in localStorage 'mx_pass')
|
||||||
|
cachedPassword: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
Phases: {
|
Phases: {
|
||||||
|
@ -121,10 +124,10 @@ module.exports = React.createClass({
|
||||||
matrixClient: MatrixClientPeg.get(),
|
matrixClient: MatrixClientPeg.get(),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickChange: function() {
|
onClickChange: function() {
|
||||||
var old_password = this.refs.old_input.value;
|
var old_password = this.props.cachedPassword || this.refs.old_input.value;
|
||||||
var new_password = this.refs.new_input.value;
|
var new_password = this.refs.new_input.value;
|
||||||
var confirm_password = this.refs.confirm_input.value;
|
var confirm_password = this.refs.confirm_input.value;
|
||||||
var err = this.props.onCheckPassword(
|
var err = this.props.onCheckPassword(
|
||||||
|
@ -139,23 +142,28 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var rowClassName = this.props.rowClassName;
|
const rowClassName = this.props.rowClassName;
|
||||||
var rowLabelClassName = this.props.rowLabelClassName;
|
const rowLabelClassName = this.props.rowLabelClassName;
|
||||||
var rowInputClassName = this.props.rowInputClassName;
|
const rowInputClassName = this.props.rowInputClassName;
|
||||||
var buttonClassName = this.props.buttonClassName;
|
const buttonClassName = this.props.buttonClassName;
|
||||||
|
|
||||||
|
let currentPassword = null;
|
||||||
|
if (!this.props.cachedPassword) {
|
||||||
|
currentPassword = <div className={rowClassName}>
|
||||||
|
<div className={rowLabelClassName}>
|
||||||
|
<label htmlFor="passwordold">Current password</label>
|
||||||
|
</div>
|
||||||
|
<div className={rowInputClassName}>
|
||||||
|
<input id="passwordold" type="password" ref="old_input" />
|
||||||
|
</div>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.state.phase) {
|
switch (this.state.phase) {
|
||||||
case this.Phases.Edit:
|
case this.Phases.Edit:
|
||||||
return (
|
return (
|
||||||
<div className={this.props.className}>
|
<div className={this.props.className}>
|
||||||
<div className={rowClassName}>
|
{ currentPassword }
|
||||||
<div className={rowLabelClassName}>
|
|
||||||
<label htmlFor="passwordold">Current password</label>
|
|
||||||
</div>
|
|
||||||
<div className={rowInputClassName}>
|
|
||||||
<input id="passwordold" type="password" ref="old_input" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className={rowClassName}>
|
<div className={rowClassName}>
|
||||||
<div className={rowLabelClassName}>
|
<div className={rowLabelClassName}>
|
||||||
<label htmlFor="password1">New password</label>
|
<label htmlFor="password1">New password</label>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue