FIX: store registration ip address when creating user via SSO (#26121)

This commit is contained in:
Arpit Jalan 2024-03-11 15:19:37 +05:30 committed by GitHub
parent 2211ffa851
commit 1bd803d360
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 0 deletions

View File

@ -256,6 +256,7 @@ class DiscourseConnect < DiscourseConnectBase
name: resolve_name,
username: resolve_username,
ip_address: ip_address,
registration_ip_address: ip_address,
}
if SiteSetting.allow_user_locale && locale && LocaleSiteSetting.valid_value?(locale)

View File

@ -694,6 +694,26 @@ RSpec.describe DiscourseConnect do
expect(user.username).to eq short_username
end
it "stores registration ip address if it's present" do
sso = new_discourse_sso
sso.external_id = "100"
sso.email = "mail@mail.com"
user = sso.lookup_or_create_user(ip_address)
expect(user.registration_ip_address).to eq ip_address
end
it "does not store registration ip address if it's not present" do
sso = new_discourse_sso
sso.external_id = "100"
sso.email = "mail@mail.com"
user = sso.lookup_or_create_user(nil)
expect(user.registration_ip_address).to eq nil
end
it "can fill in data on way back" do
sso = make_sso