Skip to content

Commit 087eb71

Browse files
authored
Merge pull request #15 from beackers/required
fixes #14
2 parents 6db1e22 + decb0ca commit 087eb71

File tree

5 files changed

+8
-8
lines changed

5 files changed

+8
-8
lines changed

app.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def view_or_edit_user(id: int):
277277
@needs_csrf
278278
def login():
279279
if request.method == "GET":
280-
return render_template("login.html", username=session.get("username") or "", csrf=session["csrf"], loggedinas=session.get("user"))
280+
return render_template("login.html", csrf=session["csrf"], loggedinas=session.get("user"))
281281

282282
elif request.method == "POST":
283283
u = request.form
@@ -303,7 +303,8 @@ def login():
303303
user = userfunc.User(u["username"].lower())
304304
except:
305305
log.info("someone tried to log in with a username that doesn't exist")
306-
abort(400)
306+
flash("That callsign doesn't exist.\nIf it should, contact an admin.")
307+
return redirect('/login', code=301)
307308
if user.pwdhash and (check_password_hash(user.pwdhash, u["password"])):
308309
session["user"] = user.callsign
309310
return redirect("/", code=301)
@@ -312,7 +313,8 @@ def login():
312313
return redirect("/", code=301)
313314
else:
314315
log.info("someone attempted login with a wrong password")
315-
abort(403)
316+
flash("That password didn't match, can you try that again?")
317+
return redirect('/login', code=301)
316318

317319
elif request.method == "DELETE":
318320
session.clear()

myop.db

0 Bytes
Binary file not shown.

templates/add_user.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
<form action="/control/user/add" method="POST">
1515
<label for="callsign">Callsign:</label>
16-
<input type="text" id="callsign" name="callsign"><br>
16+
<input type="text" id="callsign" name="callsign" required><br>
1717
<label for="name">Name:</label>
1818
<input type="text" id="name" name="name"><br>
1919
<label for="permissions">Requested permissions:</label>

templates/control.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
<tr style="background-color: gray;">
2020
<td>Name</td>
2121
<td>Callsign</td>
22-
<td>Permissions</td>
2322
<td>Edit Link</td>
2423
</tr>
2524
{% for u in users%}
2625
<tr>
2726
<td>{{ u.name }}</td>
2827
<td>{{ u.callsign }}</td>
29-
<td>{{ u.permissions }}</td>
3028
<td>
3129
<form action="/control/user/{{ u.id }}" method="get">
3230
<button type="submit">View</button>

templates/login.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<div id="navdiv"></div>
1212
</nav>
1313
{% with msgs = get_flashed_messages() %}
14-
{% if messages %}
14+
{% if msgs %}
1515
{% for msg in msgs %}
1616
<div class="flashes">
1717
<p>{{ msg }}</p>
@@ -22,7 +22,7 @@
2222
{% if not loggedinas %}
2323
<form action="/login" method="POST">
2424
<label for="username">Call sign:</label>
25-
<input type="text" id="username" name="username" value="{{ username }}"><br>
25+
<input type="text" id="username" name="username" required><br>
2626
<label for="password">Password:</label>
2727
<input type="password" id="password" name="password"><br>
2828
<input type="hidden" name="csrf" value="{{ csrf }}">

0 commit comments

Comments
 (0)