Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add a identifier in Edly Profile for social auth user #596

Open
wants to merge 3 commits into
base: develop-koa
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions cms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 0 additions & 6 deletions cms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 0 additions & 3 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
6 changes: 0 additions & 6 deletions lms/envs/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +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',
None
)

# MIXPANEL ANALYTICS PROJECT TOKEN
MIXPANEL_PROJECT_TOKEN = ENV_TOKENS.get(
'MIXPANEL_PROJECT_TOKEN',
Expand Down
10 changes: 9 additions & 1 deletion openedx/core/djangoapps/user_authn/views/password_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
10 changes: 10 additions & 0 deletions openedx/features/edly/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
EdlyMultiSiteAccess,
EdlyOrganization,
EdlySubOrganization,
EdlyUserProfile,
StudentCourseProgress,
)

Expand Down Expand Up @@ -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)
1 change: 0 additions & 1 deletion openedx/features/edly/context_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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'),
),
]
5 changes: 5 additions & 0 deletions openedx/features/edly/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down