Skip to content

Commit

Permalink
Login and signup buttons redirect to respective pages
Browse files Browse the repository at this point in the history
  • Loading branch information
iltenahmet committed Feb 26, 2024
1 parent abaa2bf commit ca6fd11
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
13 changes: 9 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@
except Exception as e:
print("MongoDB connection error:", e)

@app.route("/")
@app.route("/", methods=["GET", "POST"])
def home():
# Note: (Ahmet) I will do these
# TODO: redirect to login
# TODO: redirect to sign up
if request.method == 'POST':
if 'login' in request.form:
return redirect('/login')
elif 'sign-up' in request.form:
return redirect('/signup')
elif 'play-as-guest' in request.form:
pass
# TODO: redirect to play as guest
return render_template('start.html')

# Handle authentication related stuff in authentication.py file
Expand Down
12 changes: 9 additions & 3 deletions authentication.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from flask import render_template
from flask import render_template, request, redirect, url_for
# from flask_login import LoginManager

# login_manager = LoginManager()

def login():
return render_template('login.html')
if request.method == 'POST':
## TODO: Login
return "Someone pressed the login button huh, I better log you in."
else:
return render_template('login.html')

def signup():
return render_template('signup.html')

# TODO: Handle autehentication and session management with flask-login
4 changes: 2 additions & 2 deletions templates/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
{% block container %}

<div class="card">
<form class="vertical-align" action={{action}} method="post">
<form class="vertical-align" action={{url_for('login')}} method="post">
<input class="user-input" type="username" name="username" placeholder="Username" required>
<input class="user-input" type="password" name="password" placeholder="Password" required>
<input class="button" type="submit" value="Login">
</form>
</div>

{% endblock %}
{% endblock %}
12 changes: 6 additions & 6 deletions templates/start.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ <h3>build deeper connections with people.</h3>
</div>

<div class="card">
<div class="vertical-align">
<button class="button" type="submit">Login</button>
<button class="button" type="submit">Sign Up</button>
<button class="button" type="submit">Play As Guest</button>
</div>
<form class="vertical-align" method="post">
<button class="button" type="submit" name="login">Login</button>
<button class="button" type="submit" name="sign-up">Sign Up</button>
<button class="button" type="submit" name="play-as-guest">Play As Guest</button>
</form>
</div>

{% endblock %}
{% endblock %}

0 comments on commit ca6fd11

Please sign in to comment.