-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Record the geolocation country code of the IP at the time of sign in so that it can be used for misuse detection and filtering.
- Loading branch information
1 parent
fa059ec
commit b1cf0da
Showing
6 changed files
with
32 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddCountryToUserSignIns < ActiveRecord::Migration[6.1] | ||
def change | ||
add_column :user_sign_ins, :country, :string | ||
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
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,5 +1,5 @@ | ||
# == Schema Information | ||
# Schema version: 20220225094330 | ||
# Schema version: 20220225214524 | ||
# | ||
# Table name: user_sign_ins | ||
# | ||
|
@@ -8,6 +8,7 @@ | |
# ip :inet | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# country :string | ||
# | ||
require 'spec_helper' | ||
|
||
|
@@ -68,7 +69,7 @@ | |
|
||
let(:sign_in_2) do | ||
user = FactoryBot.create(:user, name: 'James', email: '[email protected]') | ||
FactoryBot.create(:user_sign_in, ip: '2.2.2.2', user: user) | ||
FactoryBot.create(:user_sign_in, ip: '2.2.2.2', country: 'XY', user: user) | ||
end | ||
|
||
let(:sign_in_3) do | ||
|
@@ -111,6 +112,11 @@ | |
let(:query) { 'example.com' } | ||
it { is_expected.to match_array([sign_in_2, sign_in_1]) } | ||
end | ||
|
||
context 'when given a country' do | ||
let(:query) { 'XY' } | ||
it { is_expected.to match_array([sign_in_2]) } | ||
end | ||
end | ||
|
||
describe '#other_users' do | ||
|