DEV: Deprecate OAuth2Authenticator and OAuth2UserInfo (#15427)

These have been superseded by ManagedAuthenticator and UserAssociatedAccount. For more information, see https://meta.discourse.org/t/106695
This commit is contained in:
David Taylor 2022-01-06 16:50:18 +00:00 committed by GitHub
parent c0bb775f3f
commit 78d0ec35a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 5 additions and 5 deletions

View File

@ -3,6 +3,9 @@
class Oauth2UserInfo < ActiveRecord::Base
belongs_to :user
after_initialize do
Discourse.deprecate("Oauth2UserInfo is deprecated. Use `ManagedAuthenticator` and `UserAssociatedAccount` instead. For more information, see https://meta.discourse.org/t/106695", drop_from: '2.9.0', output_in_test: true)
end
end
# == Schema Information

View File

@ -8,6 +8,7 @@ class Auth::OAuth2Authenticator < Auth::Authenticator
# only option at the moment is :trusted
def initialize(name, opts = {})
Discourse.deprecate("OAuth2Authenticator is deprecated. Use `ManagedAuthenticator` and `UserAssociatedAccount` instead. For more information, see https://meta.discourse.org/t/106695", drop_from: '2.9.0', output_in_test: true)
@name = name
@opts = opts
end

View File

@ -876,7 +876,7 @@ module Discourse
digest = Digest::MD5.hexdigest(warning)
redis_key = "deprecate-notice-#{digest}"
if !Discourse.redis.without_namespace.get(redis_key)
if Rails.logger && !Discourse.redis.without_namespace.get(redis_key)
Rails.logger.warn(warning)
begin
Discourse.redis.without_namespace.setex(redis_key, 3600, "x")

View File

@ -203,12 +203,10 @@ describe UserAnonymizer do
it "removes external auth associations" do
user.user_associated_accounts = [UserAssociatedAccount.create(user_id: user.id, provider_uid: "example", provider_name: "facebook")]
user.single_sign_on_record = SingleSignOnRecord.create(user_id: user.id, external_id: "example", last_payload: "looks good")
user.oauth2_user_infos = [Oauth2UserInfo.create(user_id: user.id, uid: "example", provider: "example")]
make_anonymous
user.reload
expect(user.user_associated_accounts).to be_empty
expect(user.single_sign_on_record).to eq(nil)
expect(user.oauth2_user_infos).to be_empty
end
it "removes api key" do

View File

@ -999,13 +999,11 @@ describe UserMerger do
it "deletes external auth infos of source user" do
UserAssociatedAccount.create(user_id: source_user.id, provider_name: "facebook", provider_uid: "1234")
Oauth2UserInfo.create(user_id: source_user.id, uid: "example", provider: "example")
SingleSignOnRecord.create(user_id: source_user.id, external_id: "example", last_payload: "looks good")
merge_users!
expect(UserAssociatedAccount.where(user_id: source_user.id).count).to eq(0)
expect(Oauth2UserInfo.where(user_id: source_user.id).count).to eq(0)
expect(SingleSignOnRecord.where(user_id: source_user.id).count).to eq(0)
end