mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
confirmation: Move check_prereg_key_and_redirect to registration.py.
This commit is contained in:
@@ -47,6 +47,26 @@ import ujson
|
||||
|
||||
import urllib
|
||||
|
||||
def check_prereg_key_and_redirect(request: HttpRequest, confirmation_key: str) -> HttpResponse:
|
||||
# If the key isn't valid, show the error message on the original URL
|
||||
confirmation = Confirmation.objects.filter(confirmation_key=confirmation_key).first()
|
||||
if confirmation is None or confirmation.type not in [
|
||||
Confirmation.USER_REGISTRATION, Confirmation.INVITATION, Confirmation.REALM_CREATION]:
|
||||
return render_confirmation_key_error(
|
||||
request, ConfirmationKeyException(ConfirmationKeyException.DOES_NOT_EXIST))
|
||||
try:
|
||||
get_object_from_key(confirmation_key, confirmation.type)
|
||||
except ConfirmationKeyException as exception:
|
||||
return render_confirmation_key_error(request, exception)
|
||||
|
||||
# confirm_preregistrationuser.html just extracts the confirmation_key
|
||||
# (and GET parameters) and redirects to /accounts/register, so that the
|
||||
# user can enter their information on a cleaner URL.
|
||||
return render(request, 'confirmation/confirm_preregistrationuser.html',
|
||||
context={
|
||||
'key': confirmation_key,
|
||||
'full_name': request.GET.get("full_name", None)})
|
||||
|
||||
@require_post
|
||||
def accounts_register(request: HttpRequest) -> HttpResponse:
|
||||
key = request.POST['key']
|
||||
|
||||
Reference in New Issue
Block a user