Skip to content

Commit 5b708aa

Browse files
Fixed wrong email login
1 parent 540ef67 commit 5b708aa

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

server.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,14 @@ def index():
3434

3535
@app.route('/showSummary', methods=['POST'])
3636
def showSummary():
37-
club = [club for club in clubs if club['email'] == request.form['email']][
38-
0]
39-
return render_template('welcome.html', club=club,
40-
competitions=competitions)
37+
try:
38+
club = [club for club in clubs if club['email'] == request.form['email']][
39+
0]
40+
return render_template('welcome.html', club=club,
41+
competitions=competitions)
42+
except IndexError:
43+
flash('Wrong email-please try again')
44+
return render_template('index.html')
4145

4246

4347
@app.route('/book/<competition>/<club>')

templates/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,22 @@
55
<title>GUDLFT Registration</title>
66
</head>
77
<body>
8+
89
<h1>Welcome to the GUDLFT Registration Portal!</h1>
10+
911
Please enter your secretary email to continue:
1012
<form action="showSummary" method="post">
1113
<label for="email">Email:</label>
1214
<input type="email" name="email" id=""/>
1315
<button type="submit">Enter</button>
1416
</form>
17+
18+
{% with messages = get_flashed_messages()%}
19+
{% if messages %}
20+
{% for message in messages %}
21+
{{message}}
22+
{% endfor %}
23+
{% endif %}
24+
{% endwith %}
1525
</body>
1626
</html>

tests/test_server.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,20 @@ def test_purchase_places(client, test_clubs, test_competitions, mocker):
6666

6767
assert int(test_clubs[0]['points']) == 4
6868
assert b'Great-booking complete!' in response.data
69+
70+
71+
def test_login(client):
72+
73+
response = client.post('/showSummary', data={
74+
'email': 'john@simplylift.co'
75+
})
76+
assert response.status_code == 200
77+
78+
79+
def test_wrong_login(client):
80+
81+
response = client.post('/showSummary', data={
82+
'email': 'wrong-email@test.com'
83+
})
84+
assert response.status_code == 200
85+
assert b'Wrong email-please try again' in response.data

0 commit comments

Comments
 (0)