From 4644d777bd7bb849adcfd6d04ebfb2542aff60c9 Mon Sep 17 00:00:00 2001 From: David Lee Date: Tue, 19 Jun 2018 17:30:23 -0700 Subject: [PATCH] FEATURE: add website field to SSO --- app/models/discourse_single_sign_on.rb | 5 +++++ lib/single_sign_on.rb | 2 +- spec/models/discourse_single_sign_on_spec.rb | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/models/discourse_single_sign_on.rb b/app/models/discourse_single_sign_on.rb index 9cc89bbcdc1..c910994fc2c 100644 --- a/app/models/discourse_single_sign_on.rb +++ b/app/models/discourse_single_sign_on.rb @@ -92,6 +92,11 @@ class DiscourseSingleSignOn < SingleSignOn user.user_profile.save! end + if website + user.user_profile.website = website + user.user_profile.save! + end + unless admin.nil? && moderator.nil? Group.refresh_automatic_groups!(:admins, :moderators, :staff) end diff --git a/lib/single_sign_on.rb b/lib/single_sign_on.rb index 3e449b84629..9f1c475f4c6 100644 --- a/lib/single_sign_on.rb +++ b/lib/single_sign_on.rb @@ -1,7 +1,7 @@ class SingleSignOn ACCESSORS = [:nonce, :name, :username, :email, :avatar_url, :avatar_force_update, :require_activation, :bio, :external_id, :return_sso_url, :admin, :moderator, :suppress_welcome_message, :title, - :add_groups, :remove_groups, :groups, :profile_background_url, :card_background_url] + :add_groups, :remove_groups, :groups, :profile_background_url, :card_background_url, :website] FIXNUMS = [] BOOLS = [:avatar_force_update, :admin, :moderator, :require_activation, :suppress_welcome_message] NONCE_EXPIRY_TIME = 10.minutes diff --git a/spec/models/discourse_single_sign_on_spec.rb b/spec/models/discourse_single_sign_on_spec.rb index 2aa6e6d5207..950bf944359 100644 --- a/spec/models/discourse_single_sign_on_spec.rb +++ b/spec/models/discourse_single_sign_on_spec.rb @@ -30,6 +30,7 @@ describe DiscourseSingleSignOn do sso.title = "user title" sso.custom_fields["a"] = "Aa" sso.custom_fields["b.b"] = "B.b" + sso.website = "https://www.discourse.org/" sso end @@ -49,6 +50,7 @@ describe DiscourseSingleSignOn do expect(parsed.title).to eq sso.title expect(parsed.custom_fields["a"]).to eq "Aa" expect(parsed.custom_fields["b.b"]).to eq "B.b" + expect(parsed.website).to eq sso.website end it "can do round trip parsing correctly" do