Skip to content

Fixed wrong email login #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ def index():

@app.route('/showSummary', methods=['POST'])
def showSummary():
club = [club for club in clubs if club['email'] == request.form['email']][
0]
return render_template('welcome.html', club=club,
competitions=competitions)
try:
club = [club for club in clubs if club['email'] == request.form['email']][
0]
return render_template('welcome.html', club=club,
competitions=competitions)
except IndexError:
flash('Wrong email-please try again')
return render_template('index.html')


@app.route('/book/<competition>/<club>')
Expand Down
10 changes: 10 additions & 0 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,22 @@
<title>GUDLFT Registration</title>
</head>
<body>

<h1>Welcome to the GUDLFT Registration Portal!</h1>

Please enter your secretary email to continue:
<form action="showSummary" method="post">
<label for="email">Email:</label>
<input type="email" name="email" id=""/>
<button type="submit">Enter</button>
</form>

{% with messages = get_flashed_messages()%}
{% if messages %}
{% for message in messages %}
{{message}}
{% endfor %}
{% endif %}
{% endwith %}
</body>
</html>
17 changes: 17 additions & 0 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,20 @@ def test_purchase_places(client, test_clubs, test_competitions, mocker):

assert int(test_clubs[0]['points']) == 4
assert b'Great-booking complete!' in response.data


def test_login(client):

response = client.post('/showSummary', data={
'email': 'john@simplylift.co'
})
assert response.status_code == 200


def test_wrong_login(client):

response = client.post('/showSummary', data={
'email': 'wrong-email@test.com'
})
assert response.status_code == 200
assert b'Wrong email-please try again' in response.data