mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-03 13:58:43 +00:00
Merge pull request #494 from mouse-reeve/registration-validation
Proper error handling for registration with invite
This commit is contained in:
commit
a7fe3fed75
3 changed files with 15 additions and 8 deletions
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column">
|
<div class="column">
|
||||||
<div class="block login">
|
<div class="block">
|
||||||
|
{% if valid %}
|
||||||
<h1 class="title">Create an Account</h1>
|
<h1 class="title">Create an Account</h1>
|
||||||
<div>
|
<div>
|
||||||
<form name="register" method="post" action="/user-register">
|
<form name="register" method="post" action="/user-register">
|
||||||
|
@ -11,6 +12,12 @@
|
||||||
{% include 'snippets/register_form.html' %}
|
{% include 'snippets/register_form.html' %}
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="content">
|
||||||
|
<h1 class="title">Permission Denied</h1>
|
||||||
|
<p>Sorry! This invite code is no longer valid.</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column">
|
<div class="column">
|
||||||
|
|
|
@ -81,8 +81,12 @@ def register(request):
|
||||||
if errors:
|
if errors:
|
||||||
data = {
|
data = {
|
||||||
'login_form': forms.LoginForm(),
|
'login_form': forms.LoginForm(),
|
||||||
'register_form': form
|
'register_form': form,
|
||||||
|
'invite': invite,
|
||||||
|
'valid': invite.valid() if invite else True,
|
||||||
}
|
}
|
||||||
|
if invite:
|
||||||
|
return TemplateResponse(request, 'invite.html', data)
|
||||||
return TemplateResponse(request, 'login.html', data)
|
return TemplateResponse(request, 'login.html', data)
|
||||||
|
|
||||||
username = '%s@%s' % (localname, DOMAIN)
|
username = '%s@%s' % (localname, DOMAIN)
|
||||||
|
|
|
@ -377,17 +377,13 @@ def invite_page(request, code):
|
||||||
''' endpoint for sending invites '''
|
''' endpoint for sending invites '''
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
try:
|
invite = get_object_or_404(models.SiteInvite, code=code)
|
||||||
invite = models.SiteInvite.objects.get(code=code)
|
|
||||||
if not invite.valid():
|
|
||||||
raise PermissionDenied
|
|
||||||
except models.SiteInvite.DoesNotExist:
|
|
||||||
raise PermissionDenied
|
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
'title': 'Join',
|
'title': 'Join',
|
||||||
'register_form': forms.RegisterForm(),
|
'register_form': forms.RegisterForm(),
|
||||||
'invite': invite,
|
'invite': invite,
|
||||||
|
'valid': invite.valid() if invite else True,
|
||||||
}
|
}
|
||||||
return TemplateResponse(request, 'invite.html', data)
|
return TemplateResponse(request, 'invite.html', data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue