From d1611874dd77463468d29292a109f7ee3ac116a1 Mon Sep 17 00:00:00 2001 From: Anas Hameed Date: Mon, 11 Nov 2024 23:38:44 +0500 Subject: [PATCH 1/3] Fix: Add a identifier for social social auth for client-setup linked admin. --- .../user_authn/views/password_reset.py | 10 +++++++++- openedx/features/edly/admin.py | 10 ++++++++++ .../0016_edlyuserprofile_is_social_user.py | 18 ++++++++++++++++++ openedx/features/edly/models.py | 5 +++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 openedx/features/edly/migrations/0016_edlyuserprofile_is_social_user.py diff --git a/openedx/core/djangoapps/user_authn/views/password_reset.py b/openedx/core/djangoapps/user_authn/views/password_reset.py index 6d3ad9a35b6b..6c6b60f23032 100644 --- a/openedx/core/djangoapps/user_authn/views/password_reset.py +++ b/openedx/core/djangoapps/user_authn/views/password_reset.py @@ -42,6 +42,7 @@ from openedx.core.djangoapps.user_authn.message_types import PasswordReset, PasswordResetSuccess from openedx.core.djangolib.markup import HTML from openedx.features.edly.utils import user_belongs_to_edly_sub_organization +from openedx.features.edly.models import EdlyUserProfile from common.djangoapps.student.forms import send_account_recovery_email_for_user from common.djangoapps.student.models import AccountRecovery from common.djangoapps.util.json_request import JsonResponse @@ -623,8 +624,15 @@ def password_change_request_handler(request): if email: try: - request_password_change(email, request.is_secure()) user = user if user.is_authenticated else _get_user_from_email(email=email) + profile = EdlyUserProfile.objects.filter(user=user).first() + if profile and profile.is_social_user: + return HttpResponse( + _("Your account uses social login; password reset isn't available."), + status=400 + ) + + request_password_change(email, request.is_secure()) destroy_oauth_tokens(user) except errors.UserNotFound: AUDIT_LOG.info("Invalid password reset attempt") diff --git a/openedx/features/edly/admin.py b/openedx/features/edly/admin.py index 6f2fef7e15a1..a3742c1dcfa2 100644 --- a/openedx/features/edly/admin.py +++ b/openedx/features/edly/admin.py @@ -8,6 +8,7 @@ EdlyMultiSiteAccess, EdlyOrganization, EdlySubOrganization, + EdlyUserProfile, StudentCourseProgress, ) @@ -79,8 +80,17 @@ class EdlyMultisiteAccessAdmin(admin.ModelAdmin): def user_email(self, obj): return obj.user.email +class EdlyUserProfileAdmin(admin.ModelAdmin): + """ + Admin interface for the "EdlyMultiSiteAccess" object. + """ + list_display = ["user", "is_blocked", "is_social_user"] + list_filter = ["is_blocked", "is_social_user"] + search_fields = ["user__username", "user__email"] + admin.site.register(StudentCourseProgress, StudentCourseProgressAdmin) admin.site.register(EdlyOrganization, EdlyOrganizationAdmin) admin.site.register(EdlySubOrganization, EdlySubOrganizationAdmin) admin.site.register(EdlyMultiSiteAccess, EdlyMultisiteAccessAdmin) +admin.site.register(EdlyUserProfile, EdlyUserProfileAdmin) diff --git a/openedx/features/edly/migrations/0016_edlyuserprofile_is_social_user.py b/openedx/features/edly/migrations/0016_edlyuserprofile_is_social_user.py new file mode 100644 index 000000000000..5401e717be70 --- /dev/null +++ b/openedx/features/edly/migrations/0016_edlyuserprofile_is_social_user.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.24 on 2024-11-07 13:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('edly', '0015_delete_chatlywidget'), + ] + + operations = [ + migrations.AddField( + model_name='edlyuserprofile', + name='is_social_user', + field=models.BooleanField(default=False, help_text='Record that the user is linked with social oauth through free trial.', verbose_name='social user'), + ), + ] diff --git a/openedx/features/edly/models.py b/openedx/features/edly/models.py index d2197cdc006f..f681f3003b53 100644 --- a/openedx/features/edly/models.py +++ b/openedx/features/edly/models.py @@ -92,6 +92,11 @@ class EdlyUserProfile(models.Model): verbose_name='Blocked', help_text=_('Block/Unblock user from logging in to the platform.') ) + is_social_user = models.BooleanField( + default=False, + verbose_name='social user', + help_text=_('Record that the user is linked with social oauth through free trial.') + ) @property def get_linked_edly_sub_organizations(self): From 7f22f82400a51e9dbc2b4bb719fb95f483c882a4 Mon Sep 17 00:00:00 2001 From: Anas Hameed Date: Fri, 15 Nov 2024 19:48:34 +0500 Subject: [PATCH 2/3] Revert "Adding Hotjar Tracking ID Variable to studio and lms setting files" This reverts commit ee0b0b1be5d3d13e8ab3a0f4a99a615fe21a1c53. --- cms/envs/common.py | 3 --- cms/envs/production.py | 6 ------ lms/envs/devstack.py | 3 +++ lms/envs/production.py | 5 +---- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index d9d3e861f600..1af15daa0662 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -2460,9 +2460,6 @@ FAVICON_URL = None DEFAULT_EMAIL_LOGO_URL = 'https://edx-cdn.org/v3/default/logo.png' -# HOTJAR ANALYTICS -HOTJAR_TRACKING_ID = None - # MIXPANEL ANALYTICS PROJECT TOKEN MIXPANEL_PROJECT_TOKEN = 'replace-me' diff --git a/cms/envs/production.py b/cms/envs/production.py index 59826ed89a4f..5826fe2a0aa8 100644 --- a/cms/envs/production.py +++ b/cms/envs/production.py @@ -583,12 +583,6 @@ def get_env_setting(setting): 'queue': UPDATE_SEARCH_INDEX_JOB_QUEUE}, } -# HOTJAR ANALYTICS -HOTJAR_TRACKING_ID = ENV_TOKENS.get( - 'HOTJAR_TRACKING_ID', - None -) - # MIXPANEL ANALYTICS PROJECT TOKEN MIXPANEL_PROJECT_TOKEN = ENV_TOKENS.get( 'MIXPANEL_PROJECT_TOKEN', diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 8519eab6f9b9..62a20362ac39 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -138,6 +138,9 @@ def should_show_debug_toolbar(request): FEATURES['AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING'] = True +# HOTJAR ANALYTICS +HOTJAR_TRACKING_ID = None + ########################### External REST APIs ################################# FEATURES['ENABLE_OAUTH2_PROVIDER'] = True FEATURES['ENABLE_MOBILE_REST_API'] = True diff --git a/lms/envs/production.py b/lms/envs/production.py index 313125b5e8f2..180517742645 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -668,10 +668,7 @@ def get_env_setting(setting): GOOGLE_SITE_VERIFICATION_ID = ENV_TOKENS.get('GOOGLE_SITE_VERIFICATION_ID') # HOTJAR ANALYTICS -HOTJAR_TRACKING_ID = ENV_TOKENS.get( - 'HOTJAR_TRACKING_ID', - None -) +HOTJAR_TRACKING_ID = ENV_TOKENS.get('HOTJAR_TRACKING_ID') # MIXPANEL ANALYTICS PROJECT TOKEN MIXPANEL_PROJECT_TOKEN = ENV_TOKENS.get( From 43b5fcf6799f9a71db547efc56f46a48d4de084e Mon Sep 17 00:00:00 2001 From: Anas Hameed Date: Fri, 15 Nov 2024 19:53:36 +0500 Subject: [PATCH 3/3] Revert: the partial(hotjar) change from commit c02f4b #291 --- lms/envs/common.py | 3 --- lms/envs/devstack.py | 3 --- lms/envs/production.py | 3 --- openedx/features/edly/context_processor.py | 1 - 4 files changed, 10 deletions(-) diff --git a/lms/envs/common.py b/lms/envs/common.py index f9d6a8ce2674..33735fc8bf64 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -1212,9 +1212,6 @@ def _make_mako_template_dirs(settings): GOOGLE_ANALYTICS_LINKEDIN = 'GOOGLE_ANALYTICS_LINKEDIN_DUMMY' GOOGLE_ANALYTICS_TRACKING_ID = None -# HOTJAR ANALYTICS -HOTJAR_TRACKING_ID = None - # MIXPANEL ANALYTICS PROJECT TOKEN MIXPANEL_PROJECT_TOKEN = 'replace-me' diff --git a/lms/envs/devstack.py b/lms/envs/devstack.py index 62a20362ac39..8519eab6f9b9 100644 --- a/lms/envs/devstack.py +++ b/lms/envs/devstack.py @@ -138,9 +138,6 @@ def should_show_debug_toolbar(request): FEATURES['AUTOMATIC_VERIFY_STUDENT_IDENTITY_FOR_TESTING'] = True -# HOTJAR ANALYTICS -HOTJAR_TRACKING_ID = None - ########################### External REST APIs ################################# FEATURES['ENABLE_OAUTH2_PROVIDER'] = True FEATURES['ENABLE_MOBILE_REST_API'] = True diff --git a/lms/envs/production.py b/lms/envs/production.py index 180517742645..b6534c3bdc7d 100644 --- a/lms/envs/production.py +++ b/lms/envs/production.py @@ -667,9 +667,6 @@ def get_env_setting(setting): GOOGLE_ANALYTICS_LINKEDIN = AUTH_TOKENS.get('GOOGLE_ANALYTICS_LINKEDIN') GOOGLE_SITE_VERIFICATION_ID = ENV_TOKENS.get('GOOGLE_SITE_VERIFICATION_ID') -# HOTJAR ANALYTICS -HOTJAR_TRACKING_ID = ENV_TOKENS.get('HOTJAR_TRACKING_ID') - # MIXPANEL ANALYTICS PROJECT TOKEN MIXPANEL_PROJECT_TOKEN = ENV_TOKENS.get( 'MIXPANEL_PROJECT_TOKEN', diff --git a/openedx/features/edly/context_processor.py b/openedx/features/edly/context_processor.py index 1a926fbea927..de89bdafdbf2 100644 --- a/openedx/features/edly/context_processor.py +++ b/openedx/features/edly/context_processor.py @@ -67,7 +67,6 @@ def edly_app_context(request): # pylint: disable=unused-argument 'footer_url': marketing_link('FOOTER'), 'gtm_id': configuration_helpers.get_value('GTM_ID'), 'ga_id': configuration_helpers.get_value('GA_ID'), - 'hotjar_id': settings.HOTJAR_TRACKING_ID, 'mixpanel_project_token': settings.MIXPANEL_PROJECT_TOKEN, 'usetiful_token': settings.USETIFUL_TOKEN, 'is_mobile_app': is_request_from_mobile_app(request)