mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: support SSO website and location overrides
Add location and website + the ability to override using SSO using the `sso_overrides_location` and `sso_overrides_website` site settings.
This commit is contained in:
@@ -48,6 +48,16 @@ export default Controller.extend({
|
||||
return canChangeBio;
|
||||
},
|
||||
|
||||
@discourseComputed("model.can_change_location")
|
||||
canChangeLocation(canChangeLocation) {
|
||||
return canChangeLocation;
|
||||
},
|
||||
|
||||
@discourseComputed("model.can_change_website")
|
||||
canChangeWebsite(canChangeWebsite) {
|
||||
return canChangeWebsite;
|
||||
},
|
||||
|
||||
actions: {
|
||||
showFeaturedTopicModal() {
|
||||
showModal("feature-topic-on-profile", {
|
||||
|
||||
@@ -17,19 +17,23 @@
|
||||
{{d-button icon="globe" label="user.use_current_timezone" action=(action "useCurrentTimezone") }}
|
||||
</div>
|
||||
|
||||
<div class="control-group pref-location">
|
||||
<label class="control-label">{{i18n "user.location"}}</label>
|
||||
<div class="controls">
|
||||
{{input type="text" value=model.location class="input-xxlarge" id="edit-location"}}
|
||||
{{#if model.can_change_location}}
|
||||
<div class="control-group pref-location">
|
||||
<label class="control-label">{{i18n "user.location"}}</label>
|
||||
<div class="controls">
|
||||
{{input type="text" value=model.location class="input-xxlarge" id="edit-location"}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="control-group pref-website">
|
||||
<label class="control-label">{{i18n "user.website"}}</label>
|
||||
<div class="controls">
|
||||
{{input type="text" value=model.website class="input-xxlarge"}}
|
||||
{{#if model.can_change_website}}
|
||||
<div class="control-group pref-website">
|
||||
<label class="control-label">{{i18n "user.website"}}</label>
|
||||
<div class="controls">
|
||||
{{input type="text" value=model.website class="input-xxlarge"}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#each userFields as |uf|}}
|
||||
<div class="control-group">
|
||||
|
||||
@@ -117,6 +117,11 @@ class DiscourseSingleSignOn < SingleSignOn
|
||||
user.user_profile.save!
|
||||
end
|
||||
|
||||
if location
|
||||
user.user_profile.location = location
|
||||
user.user_profile.save!
|
||||
end
|
||||
|
||||
unless admin.nil? && moderator.nil?
|
||||
Group.refresh_automatic_groups!(:admins, :moderators, :staff)
|
||||
end
|
||||
|
||||
@@ -51,6 +51,8 @@ class UserSerializer < UserCardSerializer
|
||||
:ignored_usernames,
|
||||
:mailing_list_posts_per_day,
|
||||
:can_change_bio,
|
||||
:can_change_location,
|
||||
:can_change_website,
|
||||
:user_api_keys,
|
||||
:user_auth_tokens
|
||||
|
||||
@@ -108,6 +110,14 @@ class UserSerializer < UserCardSerializer
|
||||
!(SiteSetting.enable_sso && SiteSetting.sso_overrides_bio)
|
||||
end
|
||||
|
||||
def can_change_location
|
||||
!(SiteSetting.enable_sso && SiteSetting.sso_overrides_location)
|
||||
end
|
||||
|
||||
def can_change_website
|
||||
!(SiteSetting.enable_sso && SiteSetting.sso_overrides_website)
|
||||
end
|
||||
|
||||
def user_api_keys
|
||||
keys = object.user_api_keys.where(revoked_at: nil).map do |k|
|
||||
{
|
||||
|
||||
@@ -27,6 +27,8 @@ class WebHookUserSerializer < UserSerializer
|
||||
gravatar_avatar_upload_id
|
||||
custom_avatar_upload_id
|
||||
can_change_bio
|
||||
can_change_location
|
||||
can_change_website
|
||||
user_api_keys
|
||||
group_users
|
||||
user_auth_tokens
|
||||
|
||||
@@ -52,13 +52,19 @@ class UserUpdater
|
||||
|
||||
def update(attributes = {})
|
||||
user_profile = user.user_profile
|
||||
user_profile.location = attributes.fetch(:location) { user_profile.location }
|
||||
user_profile.dismissed_banner_key = attributes[:dismissed_banner_key] if attributes[:dismissed_banner_key].present?
|
||||
user_profile.website = format_url(attributes.fetch(:website) { user_profile.website })
|
||||
unless SiteSetting.enable_sso && SiteSetting.sso_overrides_bio
|
||||
user_profile.bio_raw = attributes.fetch(:bio_raw) { user_profile.bio_raw }
|
||||
end
|
||||
|
||||
unless SiteSetting.enable_sso && SiteSetting.sso_overrides_location
|
||||
user_profile.location = attributes.fetch(:location) { user_profile.location }
|
||||
end
|
||||
|
||||
unless SiteSetting.enable_sso && SiteSetting.sso_overrides_website
|
||||
user_profile.website = format_url(attributes.fetch(:website) { user_profile.website })
|
||||
end
|
||||
|
||||
if attributes[:profile_background_upload_url] == ""
|
||||
user_profile.profile_background_upload_id = nil
|
||||
elsif upload = Upload.get_from_url(attributes[:profile_background_upload_url])
|
||||
|
||||
Reference in New Issue
Block a user