diff --git a/app/controllers/external_controller.rb b/app/controllers/external_controller.rb index ec57eb1006..702fd8633a 100644 --- a/app/controllers/external_controller.rb +++ b/app/controllers/external_controller.rb @@ -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 diff --git a/sample.env b/sample.env index ecb667e219..d90f6dea9b 100644 --- a/sample.env +++ b/sample.env @@ -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=