flatten out passwordSafe as it was a derived state value
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
09a4af49f3
commit
93a608a644
1 changed files with 5 additions and 7 deletions
|
@ -79,7 +79,6 @@ export default createReactClass({
|
||||||
password: this.props.defaultPassword || "",
|
password: this.props.defaultPassword || "",
|
||||||
passwordConfirm: this.props.defaultPassword || "",
|
passwordConfirm: this.props.defaultPassword || "",
|
||||||
passwordComplexity: null,
|
passwordComplexity: null,
|
||||||
passwordSafe: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -291,22 +290,21 @@ export default createReactClass({
|
||||||
}
|
}
|
||||||
const { scorePassword } = await import('../../../utils/PasswordScorer');
|
const { scorePassword } = await import('../../../utils/PasswordScorer');
|
||||||
const complexity = scorePassword(value);
|
const complexity = scorePassword(value);
|
||||||
const safe = complexity.score >= PASSWORD_MIN_SCORE;
|
|
||||||
const allowUnsafe = SdkConfig.get()["dangerously_allow_unsafe_and_insecure_passwords"];
|
|
||||||
this.setState({
|
this.setState({
|
||||||
passwordComplexity: complexity,
|
passwordComplexity: complexity,
|
||||||
passwordSafe: safe,
|
|
||||||
});
|
});
|
||||||
|
const safe = complexity.score >= PASSWORD_MIN_SCORE;
|
||||||
|
const allowUnsafe = SdkConfig.get()["dangerously_allow_unsafe_and_insecure_passwords"];
|
||||||
return allowUnsafe || safe;
|
return allowUnsafe || safe;
|
||||||
},
|
},
|
||||||
valid: function() {
|
valid: function() {
|
||||||
// Unsafe passwords that are valid are only possible through a
|
// Unsafe passwords that are valid are only possible through a
|
||||||
// configuration flag. We'll print some helper text to signal
|
// configuration flag. We'll print some helper text to signal
|
||||||
// to the user that their password is allowed, but unsafe.
|
// to the user that their password is allowed, but unsafe.
|
||||||
if (!this.state.passwordSafe) {
|
if (this.state.passwordComplexity.score >= PASSWORD_MIN_SCORE) {
|
||||||
return _t("Password is allowed, but unsafe");
|
|
||||||
}
|
|
||||||
return _t("Nice, strong password!");
|
return _t("Nice, strong password!");
|
||||||
|
}
|
||||||
|
return _t("Password is allowed, but unsafe");
|
||||||
},
|
},
|
||||||
invalid: function() {
|
invalid: function() {
|
||||||
const complexity = this.state.passwordComplexity;
|
const complexity = this.state.passwordComplexity;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue