1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-24 18:47:23 +00:00

leave fields filled after invalid login attempt

This commit is contained in:
Ozzie Isaacs 2023-01-29 13:20:22 +01:00
parent 6afb429185
commit 189da65fac
2 changed files with 6 additions and 4 deletions

View File

@ -7,11 +7,11 @@
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="form-group">
<label for="username">{{_('Username')}}</label>
<input type="text" class="form-control" id="username" name="username" autocapitalize="off" placeholder="{{_('Username')}}">
<input type="text" class="form-control" id="username" name="username" autocapitalize="off" placeholder="{{_('Username')}}" value="{{ username }}">
</div>
<div class="form-group">
<label for="password">{{_('Password')}}</label>
<input type="password" class="form-control" id="password" name="password" placeholder="{{_('Password')}}">
<input type="password" class="form-control" id="password" name="password" placeholder="{{_('Password')}}" value="{{ password }}">
</div>
<div class="checkbox">
<label>

View File

@ -1285,7 +1285,7 @@ def handle_login_user(user, remember, message, category):
return redirect_back(url_for("web.index"))
def render_login():
def render_login(username="", password=""):
next_url = request.args.get('next', default=url_for("web.index"), type=str)
if url_for("web.logout") == next_url:
next_url = url_for("web.index")
@ -1293,6 +1293,8 @@ def render_login():
title=_("Login"),
next_url=next_url,
config=config,
username=username,
password=password,
oauth_check=oauth_check,
mail=config.get_mail_server_configured(), page="login")
@ -1373,7 +1375,7 @@ def login_post():
else:
log.warning('Login failed for user "{}" IP-address: {}'.format(form['username'], ip_address))
flash(_(u"Wrong Username or Password"), category="error")
return render_login()
return render_login(form.get("username", ""), form.get("password", ""))
@web.route('/logout')