mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
parent
671469bcc7
commit
3fedb2ad20
@ -4,7 +4,7 @@ class UserAssociatedAccount < ActiveRecord::Base
|
||||
def self.cleanup!
|
||||
# This happens when a user starts the registration flow, but doesn't complete it
|
||||
# Keeping the rows doesn't cause any technical issue, but we shouldn't store PII unless it's attached to a user
|
||||
self.where("user_id IS NULL AND updated_at < ?", 1.day.ago).destroy_all
|
||||
self.where("user_id IS NULL AND updated_at < ?", 1.day.ago).delete_all
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -117,13 +117,12 @@ describe Auth::ManagedAuthenticator do
|
||||
|
||||
context 'when no matching user' do
|
||||
it 'returns the correct information' do
|
||||
result = nil
|
||||
expect {
|
||||
result = authenticator.after_authenticate(hash)
|
||||
expect(result.user).to eq(nil)
|
||||
expect(result.username).to eq("IAmGroot")
|
||||
expect(result.email).to eq("awesome@example.com")
|
||||
}.to change { UserAssociatedAccount.count }.by(1)
|
||||
expect(result.user).to eq(nil)
|
||||
expect(result.username).to eq("IAmGroot")
|
||||
expect(result.email).to eq("awesome@example.com")
|
||||
expect(UserAssociatedAccount.last.user).to eq(nil)
|
||||
expect(UserAssociatedAccount.last.info["nickname"]).to eq("IAmGroot")
|
||||
end
|
||||
|
@ -6,9 +6,9 @@ describe Jobs::CleanUpAssociatedAccounts do
|
||||
it "deletes the correct records" do
|
||||
freeze_time
|
||||
|
||||
last_week = UserAssociatedAccount.create(provider_name: "twitter", provider_uid: "1", updated_at: 7.days.ago)
|
||||
today = UserAssociatedAccount.create(provider_name: "twitter", provider_uid: "12", updated_at: 12.hours.ago)
|
||||
connected = UserAssociatedAccount.create(provider_name: "twitter", provider_uid: "123", user: Fabricate(:user), updated_at: 12.hours.ago)
|
||||
last_week = UserAssociatedAccount.create!(provider_name: "twitter", provider_uid: "1", updated_at: 7.days.ago)
|
||||
today = UserAssociatedAccount.create!(provider_name: "twitter", provider_uid: "12", updated_at: 12.hours.ago)
|
||||
connected = UserAssociatedAccount.create!(provider_name: "twitter", provider_uid: "123", user: Fabricate(:user), updated_at: 12.hours.ago)
|
||||
|
||||
expect { subject }.to change { UserAssociatedAccount.count }.by(-1)
|
||||
expect(UserAssociatedAccount.all).to contain_exactly(today, connected)
|
||||
|
Loading…
Reference in New Issue
Block a user