Skip to content

Commit

Permalink
Link to the Identity provider's account settings from the account set…
Browse files Browse the repository at this point in the history
…tings (mastodon#24100)

Co-authored-by: Claire <[email protected]>
  • Loading branch information
CSDUMMI and ClearlyClaire authored Mar 17, 2023
1 parent be9a491 commit d75a1e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ApplicationController < ActionController::Base
helper_method :current_theme
helper_method :single_user_mode?
helper_method :use_seamless_external_login?
helper_method :omniauth_only?
helper_method :sso_account_settings
helper_method :whitelist_mode?

rescue_from ActionController::ParameterMissing, Paperclip::AdapterRegistry::NoHandlerError, with: :bad_request
Expand Down Expand Up @@ -118,6 +120,14 @@ def use_seamless_external_login?
Devise.pam_authentication || Devise.ldap_authentication
end

def omniauth_only?
ENV['OMNIAUTH_ONLY'] == 'true'
end

def sso_account_settings
ENV.fetch('SSO_ACCOUNT_SETTINGS')
end

def current_account
return @current_account if defined?(@current_account)

Expand Down
4 changes: 3 additions & 1 deletion app/views/auth/registrations/edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'auth_edit', novalidate: false }) do |f|
= render 'shared/error_messages', object: resource

- if !use_seamless_external_login? || resource.encrypted_password.present?
- if (!use_seamless_external_login? || resource.encrypted_password.present?) && !omniauth_only?
.fields-row
.fields-row__column.fields-group.fields-row__column-6
= f.input :email, wrapper: :with_label, input_html: { 'aria-label': t('simple_form.labels.defaults.email') }, required: true, disabled: current_account.suspended?
Expand All @@ -23,6 +23,8 @@

.actions
= f.button :button, t('generic.save_changes'), type: :submit, class: 'button', disabled: current_account.suspended?
- elsif omniauth_only? && sso_account_settings.present?
= link_to t('users.go_to_sso_account_settings'), sso_account_settings
- else
%p.hint= t('users.seamless_external_login')

Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1691,6 +1691,7 @@ en:
title: Welcome aboard, %{name}!
users:
follow_limit_reached: You cannot follow more than %{limit} people
go_to_sso_account_settings: Go to your identity provider's account settings
invalid_otp_token: Invalid two-factor code
otp_lost_help_html: If you lost access to both, you may get in touch with %{email}
seamless_external_login: You are logged in via an external service, so password and e-mail settings are not available.
Expand Down

0 comments on commit d75a1e5

Please sign in to comment.