-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Rocket <[email protected]>
- Loading branch information
1 parent
4220508
commit c7e83fa
Showing
19 changed files
with
110 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
class Users::ForgotPasswordForm | ||
include ActiveModel::Model | ||
|
||
attr_accessor :email | ||
attr_accessor :email, :spam_trap | ||
|
||
validates :email, format: { with: URI::MailTo::EMAIL_REGEXP } | ||
|
||
validates :spam_trap, absence: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,15 @@ | |
|
||
expect(response.status).to eq(422) | ||
end | ||
|
||
it "handles submission by bots" do | ||
post :send_reset_password_instructions, params: { | ||
users_forgot_password_form: { email: "[email protected]", spam_trap: "I am a bot" }, | ||
locale: "en" | ||
} | ||
|
||
expect(response.status).to eq(422) | ||
end | ||
end | ||
|
||
describe "GET reset" do | ||
|
@@ -95,5 +104,19 @@ | |
|
||
expect(response.status).to eq(422) | ||
end | ||
|
||
it "handles submission by bots" do | ||
post :confirm_reset, params: { | ||
users_reset_password_form: { | ||
email: "[email protected]", | ||
code: "123456", | ||
password: "password", | ||
spam_trap: "I am a bot" | ||
}, | ||
locale: "en" | ||
} | ||
|
||
expect(response.status).to eq(422) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,22 @@ | |
|
||
expect(response.status).to eq(422) | ||
end | ||
|
||
it "handles submission by bots" do | ||
email = "[email protected]" | ||
|
||
post :create, params: { | ||
users_registration_form: { | ||
email: email, | ||
password: "password", | ||
role: "employer", | ||
spam_trap: "I am a bot" | ||
}, | ||
locale: "en" | ||
} | ||
|
||
expect(response.status).to eq(422) | ||
end | ||
end | ||
|
||
describe "GET new_account_verification" do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,6 +91,21 @@ | |
expect(session[:challenge_email]).to eq("[email protected]") | ||
expect(response).to redirect_to(session_challenge_path) | ||
end | ||
|
||
it "handles submission by bots" do | ||
create(:user, uid: uid) | ||
|
||
post :create, params: { | ||
users_new_session_form: { | ||
email: "[email protected]", | ||
password: "password", | ||
spam_trap: "I am a bot" | ||
}, | ||
locale: "en" | ||
} | ||
|
||
expect(response.status).to eq(422) | ||
end | ||
end | ||
|
||
describe "GET challenge" do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,15 @@ | |
expect(form).not_to be_valid | ||
expect(form.errors.of_kind?(:email, :invalid)).to be_truthy | ||
end | ||
|
||
it "requires the honeypot field to be empty" do | ||
form = Users::NewSessionForm.new( | ||
email: "[email protected]", | ||
password: "password", | ||
spam_trap: "I am a bot" | ||
) | ||
|
||
expect(form).not_to be_valid | ||
expect(form.errors.of_kind?(:spam_trap, :present)).to be_truthy | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,4 +36,13 @@ | |
expect(form).not_to be_valid | ||
expect(form.errors.of_kind?(:email, :invalid)).to be_truthy | ||
end | ||
|
||
it "requires the honeypot field is empty" do | ||
form.email = "[email protected]" | ||
form.password = valid_password | ||
form.spam_trap = "I am a bot" | ||
|
||
expect(form).not_to be_valid | ||
expect(form.errors.of_kind?(:spam_trap, :present)).to be_truthy | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters