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

feat: add filters DEMO for Hooks Extension Framework #212

Closed
wants to merge 5 commits into from
Closed
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
8 changes: 8 additions & 0 deletions lms/envs/devstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,3 +432,11 @@ def should_show_debug_toolbar(request): # lint-amnesty, pylint: disable=missing
# Used in edx-proctoring for ID generation in lieu of SECRET_KEY - dummy value
# (ref MST-637)
PROCTORING_USER_OBFUSCATION_KEY = '85920908f28904ed733fe576320db18cabd7b6cd'

HOOK_FILTERS_CONFIG = {
"org.openedx.lms.auth.user.registration.started.v1": {
"pipeline": [
"openedx_basic_hooks.filters.pre_register.check_year_of_birth",
],
}
}
20 changes: 20 additions & 0 deletions openedx/core/djangoapps/user_authn/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
get_registration_extension_form
)
from openedx.core.djangoapps.user_authn.toggles import is_require_third_party_auth_enabled
from openedx_filters.learning.data import UserData, UserPersonalData
from openedx_filters.learning.filters import STUDENT_REGISTRATION_STARTED
from openedx_filters.exceptions import OpenEdxFilterException
from common.djangoapps.student.helpers import (
AccountValidationError,
authenticate_new_user,
Expand Down Expand Up @@ -522,6 +525,23 @@ def post(self, request):
data = request.POST.copy()
self._handle_terms_of_service(data)

try:
data = STUDENT_REGISTRATION_STARTED.execute_filter(
user=UserData(
pii=UserPersonalData(
username=data.get('username'),
email=data.get('email'),
name=data.get('name'),
)
)
)

except OpenEdxFilterException as err:
errors = {
"filter_error": [{"user_message": err.message}]
}
return self._create_response(request, errors, status_code=err.status_code)

response = self._handle_duplicate_email_username(request, data)
if response:
return response
Expand Down