summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnson Bridges <bridges.anson@gmail.com>2026-04-03 16:26:39 -0700
committerAnson Bridges <bridges.anson@gmail.com>2026-04-03 16:26:39 -0700
commit97ccdd6fedaec5b0547d7a7e138f30a3389b845a (patch)
treead6a85a52bac6558547f0db028a2c80d9ffded4f
parentdc5096c18c6b98f410fd769f989c5404de44ba71 (diff)
register page
-rw-r--r--app.py32
-rw-r--r--templates/base.html1
-rw-r--r--templates/login.html1
-rw-r--r--templates/register.html21
4 files changed, 55 insertions, 0 deletions
diff --git a/app.py b/app.py
index d6531c0..6af1163 100644
--- a/app.py
+++ b/app.py
@@ -405,6 +405,38 @@ def login():
return render_template('login.html')
+@app.route('/register', methods=['GET', 'POST'])
+def register():
+ if request.method == 'POST':
+ username = request.form['username']
+ password = request.form['password']
+ team_name = request.form['team_name']
+
+ conn = get_db()
+ c = conn.cursor()
+
+ try:
+ c.execute('''
+ INSERT INTO Users (username, password_hash, team_name)
+ VALUES (?, ?, ?)
+ ''', (username, generate_password_hash(password), team_name))
+ conn.commit()
+
+ # Auto-login after registration
+ c.execute('SELECT * FROM Users WHERE username = ?', (username,))
+ user_row = c.fetchone()
+ user = User(user_row['id'], user_row['username'], user_row['is_admin'], user_row['team_name'], user_row['team_icon'])
+ login_user(user)
+
+ flash('Account created and logged in!')
+ return redirect(url_for('index'))
+ except sqlite3.IntegrityError:
+ flash('Username already exists.')
+ finally:
+ conn.close()
+
+ return render_template('register.html')
+
@app.route('/logout')
@login_required
def logout():
diff --git a/templates/base.html b/templates/base.html
index 41fab17..56c97e7 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -27,6 +27,7 @@
<a href="{{ url_for('logout') }}">Logout ({{ current_user.username }})</a>
{% else %}
<a href="{{ url_for('login') }}">Login</a>
+ <a href="{{ url_for('register') }}">Join the League</a>
{% endif %}
</nav>
</header>
diff --git a/templates/login.html b/templates/login.html
index f8f19b6..6c8e1c2 100644
--- a/templates/login.html
+++ b/templates/login.html
@@ -13,4 +13,5 @@
</div>
<button type="submit">Login</button>
</form>
+ <p>Don't have an account? <a href="{{ url_for('register') }}">Create one here</a>.</p>
{% endblock %} \ No newline at end of file
diff --git a/templates/register.html b/templates/register.html
new file mode 100644
index 0000000..1405920
--- /dev/null
+++ b/templates/register.html
@@ -0,0 +1,21 @@
+{% extends "base.html" %}
+
+{% block content %}
+ <h2>Create New Team Account</h2>
+ <form method="POST" action="{{ url_for('register') }}">
+ <div>
+ <label for="username">Username:</label>
+ <input type="text" id="username" name="username" required>
+ </div>
+ <div>
+ <label for="password">Password:</label>
+ <input type="password" id="password" name="password" required>
+ </div>
+ <div>
+ <label for="team_name">Team Name:</label>
+ <input type="text" id="team_name" name="team_name" required>
+ </div>
+ <button type="submit">Create Account</button>
+ </form>
+ <p>Already have an account? <a href="{{ url_for('login') }}">Login here</a>.</p>
+{% endblock %} \ No newline at end of file