Skip to content

Commit

Permalink
Flag to enable email as a fallback identifyer. Solution to issue #5872 (
Browse files Browse the repository at this point in the history
#5930)

* Email fallback as discussed in Issue #5872

* fix use of wrong methode

---------

Co-authored-by: Ahmad Farhat <[email protected]>
  • Loading branch information
SebastianAppDev and farhatahmad authored Sep 16, 2024
1 parent f3dae82 commit b8cc2d3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/controllers/external_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ def create_user

user = User.find_by(external_id: credentials['uid'], provider:)

# Fallback mechanism to search by email
if user.blank? && ENV.fetch('USE_EMAIL_AS_EXTERNAL_ID_FALLBACK', 'false') == 'true'
user = User.find_by(email: credentials['info']['email'], provider:)
# Update the user's external id to the latest value to avoid using the fallback
user.update(external_id: credentials['uid']) if user.present? && credentials['uid'].present?
end

new_user = user.blank?

registration_method = SettingGetter.new(setting_name: 'RegistrationMethod', provider: current_provider).call
Expand Down
4 changes: 4 additions & 0 deletions sample.env
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ REDIS_URL=
#OPENID_CONNECT_REDIRECT=
#OPENID_CONNECT_UID_FIELD=sub

# Uncomment the following flag if you want to use EMAIL as a Unique ID backup, useful for setups with existing users who want to switch to an IDP setup.
# More information: https://github.com/bigbluebutton/greenlight/issues/5872
#USE_EMAIL_AS_EXTERNAL_ID_FALLBACK=true

# To enable hCaptcha on the user sign up and sign in, define these 2 keys
# More information: https://docs.bigbluebutton.org/greenlight/v3/install/#hcaptcha-setup
#HCAPTCHA_SITE_KEY=
Expand Down

0 comments on commit b8cc2d3

Please sign in to comment.