Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
|
| 4 |
-
from flask import Flask, render_template, url_for, redirect, request, make_response, session
|
| 5 |
import requests
|
| 6 |
from supabase import create_client, Client
|
| 7 |
import jwt
|
|
@@ -14,7 +14,7 @@ supabase: Client = create_client(url, key)
|
|
| 14 |
jwtKey: str = os.environ.get("JWTKey")
|
| 15 |
|
| 16 |
# Function Config
|
| 17 |
-
allow_signups: bool =
|
| 18 |
|
| 19 |
|
| 20 |
@app.route("/")
|
|
@@ -23,8 +23,8 @@ def index():
|
|
| 23 |
|
| 24 |
@app.route("/signup")
|
| 25 |
def signupPage():
|
| 26 |
-
if allow_signups:
|
| 27 |
-
|
| 28 |
return render_template("signin.html")
|
| 29 |
|
| 30 |
@app.route("/login")
|
|
@@ -34,6 +34,8 @@ def loginPage():
|
|
| 34 |
@app.post("/api/signup")
|
| 35 |
def signupAPI():
|
| 36 |
error = None
|
|
|
|
|
|
|
| 37 |
if request.method == 'POST':
|
| 38 |
data = json.loads(request.data)
|
| 39 |
sPass = jwt.encode({"password": data["password"]}, jwtKey, algorithm="HS256")
|
|
|
|
| 1 |
import os
|
| 2 |
import json
|
| 3 |
|
| 4 |
+
from flask import Flask, render_template, url_for, redirect, request, make_response, session, abort
|
| 5 |
import requests
|
| 6 |
from supabase import create_client, Client
|
| 7 |
import jwt
|
|
|
|
| 14 |
jwtKey: str = os.environ.get("JWTKey")
|
| 15 |
|
| 16 |
# Function Config
|
| 17 |
+
allow_signups: bool = False # Set to true when allowing a new user
|
| 18 |
|
| 19 |
|
| 20 |
@app.route("/")
|
|
|
|
| 23 |
|
| 24 |
@app.route("/signup")
|
| 25 |
def signupPage():
|
| 26 |
+
if not allow_signups:
|
| 27 |
+
abort(404)
|
| 28 |
return render_template("signin.html")
|
| 29 |
|
| 30 |
@app.route("/login")
|
|
|
|
| 34 |
@app.post("/api/signup")
|
| 35 |
def signupAPI():
|
| 36 |
error = None
|
| 37 |
+
if not allow_signups: # Security mainly. Only allow signups when I want to.
|
| 38 |
+
abort(404)
|
| 39 |
if request.method == 'POST':
|
| 40 |
data = json.loads(request.data)
|
| 41 |
sPass = jwt.encode({"password": data["password"]}, jwtKey, algorithm="HS256")
|