2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-28 23:44:16 +08:00
|
|
|
class UserAssociatedAccount < ActiveRecord::Base
|
|
|
|
belongs_to :user
|
2018-12-10 23:10:06 +08:00
|
|
|
|
|
|
|
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
|
2018-12-11 17:58:20 +08:00
|
|
|
self.where("user_id IS NULL AND updated_at < ?", 1.day.ago).delete_all
|
2018-12-10 23:10:06 +08:00
|
|
|
end
|
2018-11-28 23:44:16 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: user_associated_accounts
|
|
|
|
#
|
2019-05-03 06:34:12 +08:00
|
|
|
# id :bigint not null, primary key
|
2018-11-28 23:44:16 +08:00
|
|
|
# provider_name :string not null
|
|
|
|
# provider_uid :string not null
|
2018-12-10 23:10:06 +08:00
|
|
|
# user_id :integer
|
2018-11-28 23:44:16 +08:00
|
|
|
# last_used :datetime not null
|
|
|
|
# info :jsonb not null
|
|
|
|
# credentials :jsonb not null
|
|
|
|
# extra :jsonb not null
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# associated_accounts_provider_uid (provider_name,provider_uid) UNIQUE
|
|
|
|
# associated_accounts_provider_user (provider_name,user_id) UNIQUE
|
|
|
|
#
|