Skip to content

Commit

Permalink
Merge pull request #26 from cleobnvntra/bugfix-issue22
Browse files Browse the repository at this point in the history
added error messages to login page
  • Loading branch information
vigneshs-dev authored Oct 9, 2024
2 parents 2a8a180 + 4cc941d commit 8e1fcb0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def login():

if user is None:
flash("User not found. Please register first.", 'error')
return redirect(url_for('register'))
return redirect(url_for('login'))

if user and check_password_hash(user['password'], password):
session['user_id'] = user['id']
Expand Down
13 changes: 13 additions & 0 deletions src/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,17 @@ a {

a:hover {
text-decoration: underline;
}

/* Error message styles */
.error-container {
background-color: #f8d7da;
border-radius: 4px;
margin-bottom: 20px;
}

.error-message {
color: #dc3545;
text-align: center;
padding: 20px;
}
10 changes: 9 additions & 1 deletion src/templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ <h2>Login</h2>

<label for="password">Password</label>
<input type="password" name="password" class="input-field" required>

{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="error-container">
<div class="error-message">{{ message }}</div>
</div>
{% endfor %}
{% endif %}
{% endwith %}
<button type="submit" class="btn-submit">Login</button>
</form>
<p>Don't have an account? <a href="/register">Register here</a>.</p>
Expand Down
Binary file modified src/votes.db
Binary file not shown.

0 comments on commit 8e1fcb0

Please sign in to comment.