mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 06:42:41 +08:00
FIX: Show error message when password is too common (#30507)
This commit is contained in:
parent
d8e8c9f1e4
commit
1c893d1725
|
@ -461,11 +461,7 @@ export default class CreateAccount extends Component.extend(
|
|||
) {
|
||||
this.rejectedEmails.pushObject(result.values.email);
|
||||
}
|
||||
if (
|
||||
result.errors &&
|
||||
result.errors.password &&
|
||||
result.errors.password.length > 0
|
||||
) {
|
||||
if (result.errors?.["user_password.password"]?.length > 0) {
|
||||
this.rejectedPasswords.pushObject(attrs.accountPassword);
|
||||
}
|
||||
this.set("formSubmitted", false);
|
||||
|
|
|
@ -338,15 +338,11 @@ export default class InvitesShowController extends Controller.extend(
|
|||
) {
|
||||
this.rejectedEmails.pushObject(result.values.email);
|
||||
}
|
||||
if (
|
||||
result.errors &&
|
||||
result.errors.password &&
|
||||
result.errors.password.length > 0
|
||||
) {
|
||||
if (result.errors?.["user_password.password"]?.length > 0) {
|
||||
this.rejectedPasswords.pushObject(this.accountPassword);
|
||||
this.rejectedPasswordsMessages.set(
|
||||
this.accountPassword,
|
||||
result.errors.password[0]
|
||||
result.errors["user_password.password"][0]
|
||||
);
|
||||
}
|
||||
if (result.message) {
|
||||
|
|
|
@ -145,7 +145,7 @@ export default class PasswordResetController extends Controller.extend(
|
|||
securityKeyRequired: false,
|
||||
errorMessage: null,
|
||||
});
|
||||
} else if (result.errors?.password?.length > 0) {
|
||||
} else if (result.errors?.["user_password.password"]?.length > 0) {
|
||||
this.rejectedPasswords.pushObject(this.accountPassword);
|
||||
this.rejectedPasswordsMessages.set(
|
||||
this.accountPassword,
|
||||
|
|
|
@ -456,11 +456,7 @@ export default class SignupPageController extends Controller.extend(
|
|||
) {
|
||||
this.rejectedEmails.pushObject(result.values.email);
|
||||
}
|
||||
if (
|
||||
result.errors &&
|
||||
result.errors.password &&
|
||||
result.errors.password.length > 0
|
||||
) {
|
||||
if (result.errors?.["user_password.password"]?.length > 0) {
|
||||
this.rejectedPasswords.pushObject(attrs.accountPassword);
|
||||
}
|
||||
this.set("formSubmitted", false);
|
||||
|
|
|
@ -22,7 +22,7 @@ acceptance("Password Reset", function (needs) {
|
|||
if (body.password === "jonesyAlienSlayer") {
|
||||
return helper.response({
|
||||
success: false,
|
||||
errors: { password: ["is the name of your cat"] },
|
||||
errors: { "user_password.password": ["is the name of your cat"] },
|
||||
friendly_messages: ["Password is the name of your cat"],
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -71,6 +71,20 @@ shared_examples "signup scenarios" do |signup_page_object, login_page_object|
|
|||
expect(page).to have_current_path("/t/#{topic.slug}/#{topic.id}")
|
||||
end
|
||||
|
||||
it "cannot signup with a common password" do
|
||||
signup_form
|
||||
.open
|
||||
.fill_email("johndoe@example.com")
|
||||
.fill_username("john")
|
||||
.fill_password("0123456789")
|
||||
expect(signup_form).to have_valid_fields
|
||||
|
||||
signup_form.click_create_account
|
||||
expect(signup_form).to have_content(
|
||||
I18n.t("activerecord.errors.models.user_password.attributes.password.common"),
|
||||
)
|
||||
end
|
||||
|
||||
context "with invite code" do
|
||||
before { SiteSetting.invite_code = "cupcake" }
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user