Skip to content
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

Add logout buttons #74

Merged
merged 1 commit into from
Mar 2, 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
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def login():
def signup():
return auth_signup()

@app.route('/logout', methods=["GET", "POST"])
def logout():
return auth_logout()

@app.route("/<username>/decks")
def allDecks(username):
if username == "guest":
Expand Down
6 changes: 4 additions & 2 deletions authentication.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask import render_template, request, redirect, url_for, session, flash
from flask_login import LoginManager, UserMixin, login_user, current_user
from flask_login import LoginManager, UserMixin, login_user, current_user, logout_user
from db import *
from pymongo import *
from werkzeug.security import generate_password_hash, check_password_hash
Expand Down Expand Up @@ -71,5 +71,7 @@ def auth_signup():
else:
return render_template('signup.html', username_taken=False, passwords_dont_match=False)


def auth_logout():
logout_user()
return redirect('/')

35 changes: 19 additions & 16 deletions templates/card.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,25 @@ <h3 id="next-question"> START </h3>

{% if isAuth %}

<button id="add-card-button" class="button2" >Add Card</button>
<button id="edit-card-button" class="button2" style="display: none">Edit</button>

<form method="post" id="delete-form">
<input type="hidden" name="question" id="delete-form-question" value=""></input>
<button id="delete-card-button" class="button2" style="display: none">Delete Card</button>
</form>

<form method="post" id="card-form" style="display: none">
<svg id="close-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="120px" height="120px">
<circle fill="#63514F" cx="15" cy="15" r="10" />
<path fill="#D9D9D9" d="M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16.414,15 c0,0,3.139,3.139,3.293,3.293c0.391,0.391,0.391,1.024,0,1.414c-0.391,0.391-1.024,0.391-1.414,0C18.139,19.554,15,16.414,15,16.414 s-3.139,3.139-3.293,3.293c-0.391,0.391-1.024,0.391-1.414,0c-0.391-0.391-0.391-1.024,0-1.414C10.446,18.139,13.586,15,13.586,15 s-3.139-3.139-3.293-3.293c-0.391-0.391-0.391-1.024,0-1.414c0.391-0.391,1.024-0.391,1.414,0C11.861,10.446,15,13.586,15,13.586 s3.139-3.139,3.293-3.293c0.391-0.391,1.024-0.391,1.414,0c0.391,0.391,0.391,1.024,0,1.414C19.554,11.861,16.414,15,16.414,15z"/>
</svg>
<textarea name="question" required></textarea>
<button class="button2">Done</button>
</form>
<button id="add-card-button" class="button2" >Add Card</button>
<button id="edit-card-button" class="button2" style="display: none">Edit</button>

<form method="post" id="delete-form">
<input type="hidden" name="question" id="delete-form-question" value=""></input>
<button id="delete-card-button" class="button2" style="display: none">Delete Card</button>
</form>

<form method="post" id="card-form" style="display: none">
<svg id="close-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="120px" height="120px">
<circle fill="#63514F" cx="15" cy="15" r="10" />
<path fill="#D9D9D9" d="M15,3C8.373,3,3,8.373,3,15c0,6.627,5.373,12,12,12s12-5.373,12-12C27,8.373,21.627,3,15,3z M16.414,15 c0,0,3.139,3.139,3.293,3.293c0.391,0.391,0.391,1.024,0,1.414c-0.391,0.391-1.024,0.391-1.414,0C18.139,19.554,15,16.414,15,16.414 s-3.139,3.139-3.293,3.293c-0.391,0.391-1.024,0.391-1.414,0c-0.391-0.391-0.391-1.024,0-1.414C10.446,18.139,13.586,15,13.586,15 s-3.139-3.139-3.293-3.293c-0.391-0.391-0.391-1.024,0-1.414c0.391-0.391,1.024-0.391,1.414,0C11.861,10.446,15,13.586,15,13.586 s3.139-3.139,3.293-3.293c0.391-0.391,1.024-0.391,1.414,0c0.391,0.391,0.391,1.024,0,1.414C19.554,11.861,16.414,15,16.414,15z"/>
</svg>
<textarea name="question" required></textarea>
<button class="button2">Done</button>
</form>

{% from 'macros.html' import logout %}
{{ logout() }}

{% endif %}

Expand Down
10 changes: 7 additions & 3 deletions templates/decks.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ <h3>{{ deck.title }}</h3>
</script>

{% if isAuth %}
<button class="add-deck">
<h3> + </h3>
</button>
<button class="add-deck">
<h3> + </h3>
</button>

<form action="{{ url_for('createDeck', username=username) }}" method="post" class="add-deck-form" style="display: none">
<p>x</p>
Expand All @@ -70,7 +70,11 @@ <h3> + </h3>
document.querySelector(".add-deck-form").style.display="none"
})
</script>

{% from 'macros.html' import logout %}
{{ logout() }}
{% endif %}


{% endblock %}

5 changes: 5 additions & 0 deletions templates/macros.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% macro logout() %}
<form action="{{ url_for('logout') }}" method="post">
<button type="submit" class="button2"> Logout </button>
</form>
{% endmacro %}
Loading