mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-03 13:58:43 +00:00
Fixes login form
This commit is contained in:
parent
3fe7b95786
commit
81e60cea16
4 changed files with 9 additions and 8 deletions
|
@ -35,7 +35,7 @@ class CustomForm(ModelForm):
|
|||
class LoginForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.User
|
||||
fields = ['username', 'password']
|
||||
fields = ['localname', 'password']
|
||||
help_texts = {f: None for f in fields}
|
||||
widgets = {
|
||||
'password': PasswordInput(),
|
||||
|
|
|
@ -119,15 +119,15 @@
|
|||
</div>
|
||||
{% else %}
|
||||
<div class="navbar-item">
|
||||
{% if request.path != '/login' and request.path != '/login/' %}
|
||||
{% if request.path != '/login' and request.path != '/login/' and request.path != '/user-login' %}
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<form name="login" method="post" action="/user-login">
|
||||
{% csrf_token %}
|
||||
<div class="field is-grouped">
|
||||
<div class="control">
|
||||
<label class="is-sr-only" for="id_username">Username:</label>
|
||||
<input type="text" name="username" maxlength="150" class="input" required="" id="id_username" placeholder="username">
|
||||
<label class="is-sr-only" for="id_localname">Username:</label>
|
||||
<input type="text" name="localname" maxlength="150" class="input" required="" id="id_localname" placeholder="username">
|
||||
</div>
|
||||
<div class="control">
|
||||
<label class="is-sr-only" for="id_password">Username:</label>
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
<form name="login" method="post" action="/user-login">
|
||||
{% csrf_token %}
|
||||
<div class="field">
|
||||
<label class="label" for="id_username">Username:</label>
|
||||
<label class="label" for="id_localname">Username:</label>
|
||||
<div class="control">
|
||||
{{ login_form.username }}
|
||||
{{ login_form.localname }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
|
|
|
@ -30,8 +30,9 @@ def user_login(request):
|
|||
''' authenticate user login '''
|
||||
login_form = forms.LoginForm(request.POST)
|
||||
|
||||
username = login_form.data['username']
|
||||
username = '%s@%s' % (username, DOMAIN)
|
||||
print(login_form.data)
|
||||
localname = login_form.data['localname']
|
||||
username = '%s@%s' % (localname, DOMAIN)
|
||||
password = login_form.data['password']
|
||||
user = authenticate(request, username=username, password=password)
|
||||
if user is not None:
|
||||
|
|
Loading…
Reference in a new issue