Consider more user inputs when calculating zxcvbn score (#11180)
* Consider more user inputs when calculating zxcvbn score * MatrixClientPeg.getHomeserverName may throw
This commit is contained in:
parent
90e65e8490
commit
4044c2aa66
3 changed files with 22 additions and 6 deletions
|
@ -31,6 +31,8 @@ interface IProps extends Omit<IInputProps, "onValidate" | "element"> {
|
|||
minScore: 0 | 1 | 2 | 3 | 4;
|
||||
value: string;
|
||||
fieldRef?: RefCallback<Field> | RefObject<Field>;
|
||||
// Additional strings such as a username used to catch bad passwords
|
||||
userInputs?: string[];
|
||||
|
||||
label: string;
|
||||
labelEnterPassword: string;
|
||||
|
@ -57,7 +59,7 @@ class PassphraseField extends PureComponent<IProps> {
|
|||
deriveData: async ({ value }): Promise<zxcvbn.ZXCVBNResult | null> => {
|
||||
if (!value) return null;
|
||||
const { scorePassword } = await import("../../../utils/PasswordScorer");
|
||||
return scorePassword(MatrixClientPeg.get(), value);
|
||||
return scorePassword(MatrixClientPeg.get(), value, this.props.userInputs);
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
|
|
|
@ -473,6 +473,7 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
|
|||
value={this.state.password}
|
||||
onChange={this.onPasswordChange}
|
||||
onValidate={this.onPasswordValidate}
|
||||
userInputs={[this.state.username]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue