forked from mirrors/bookwyrm
Show login errors from django forms
This commit is contained in:
parent
f9cb9f939a
commit
1e394a282e
2 changed files with 9 additions and 3 deletions
|
@ -133,3 +133,9 @@ th, td {
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.errorlist {
|
||||||
|
list-style: none;
|
||||||
|
font-size: 0.8em;
|
||||||
|
color: #FF1654;
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ def home(request):
|
||||||
# TODO: handle post privacy
|
# TODO: handle post privacy
|
||||||
activities = models.Activity.objects.filter(
|
activities = models.Activity.objects.filter(
|
||||||
user__in=following,
|
user__in=following,
|
||||||
|
|
||||||
).select_subclasses().order_by(
|
).select_subclasses().order_by(
|
||||||
'-created_date'
|
'-created_date'
|
||||||
)[:10]
|
)[:10]
|
||||||
|
@ -66,8 +67,7 @@ def user_login(request):
|
||||||
# authenticate user
|
# authenticate user
|
||||||
form = forms.LoginForm(request.POST)
|
form = forms.LoginForm(request.POST)
|
||||||
if not form.is_valid():
|
if not form.is_valid():
|
||||||
# TODO messaging about a login failure
|
return TemplateResponse(request, 'login.html', {'login_form': form})
|
||||||
return TemplateResponse(request, 'login.html')
|
|
||||||
|
|
||||||
username = form.data['username']
|
username = form.data['username']
|
||||||
username = '%s@%s' % (username, DOMAIN)
|
username = '%s@%s' % (username, DOMAIN)
|
||||||
|
@ -76,7 +76,7 @@ def user_login(request):
|
||||||
if user is not None:
|
if user is not None:
|
||||||
login(request, user)
|
login(request, user)
|
||||||
return redirect(request.GET.get('next', '/'))
|
return redirect(request.GET.get('next', '/'))
|
||||||
return TemplateResponse(request, 'login.html')
|
return TemplateResponse(request, 'login.html', {'login_form': form})
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in a new issue