Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,8 +23,15 @@ def jwtDecode(token):
|
|
| 23 |
return "bad", "Username/Password does not match"
|
| 24 |
|
| 25 |
def authorized(func):
|
|
|
|
|
|
|
|
|
|
| 26 |
def wrap():
|
| 27 |
-
if not "username" in session
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
return redirect(url_for("login"))
|
| 29 |
return func()
|
| 30 |
return wrap()
|
|
@@ -35,20 +42,22 @@ def index():
|
|
| 35 |
return render_template("index.html")
|
| 36 |
|
| 37 |
@app.route("/app")
|
|
|
|
| 38 |
def interApp():
|
| 39 |
return "<h1>WIP</h1>"
|
| 40 |
|
| 41 |
@app.route("/signup")
|
| 42 |
-
def
|
| 43 |
if not allow_signups:
|
| 44 |
abort(404)
|
| 45 |
return render_template("signin.html")
|
| 46 |
|
| 47 |
@app.route("/login")
|
| 48 |
-
def
|
| 49 |
return render_template("login.html")
|
| 50 |
|
| 51 |
|
|
|
|
| 52 |
@app.post("/api/signup")
|
| 53 |
def signupAPI():
|
| 54 |
error = None
|
|
@@ -63,8 +72,10 @@ def signupAPI():
|
|
| 63 |
.insert(dbData)
|
| 64 |
.execute()
|
| 65 |
)
|
|
|
|
|
|
|
| 66 |
response = dbResponse["data"][0]
|
| 67 |
-
return make_response(response), 200
|
| 68 |
|
| 69 |
@app.post("/api/login")
|
| 70 |
def loginAPI():
|
|
@@ -94,6 +105,7 @@ def loginAPI():
|
|
| 94 |
return jwtPass[1], 401
|
| 95 |
|
| 96 |
|
|
|
|
| 97 |
@app.errorhandler(404)
|
| 98 |
def not_found(e):
|
| 99 |
return render_template("404.html")
|
|
|
|
| 23 |
return "bad", "Username/Password does not match"
|
| 24 |
|
| 25 |
def authorized(func):
|
| 26 |
+
def wipe():
|
| 27 |
+
session.pop("username", None)
|
| 28 |
+
session.pop("password", None)
|
| 29 |
def wrap():
|
| 30 |
+
if not "username" in session:
|
| 31 |
+
wipe()
|
| 32 |
+
return redirect(url_for("login"))
|
| 33 |
+
if not "password" in session:
|
| 34 |
+
wipe()
|
| 35 |
return redirect(url_for("login"))
|
| 36 |
return func()
|
| 37 |
return wrap()
|
|
|
|
| 42 |
return render_template("index.html")
|
| 43 |
|
| 44 |
@app.route("/app")
|
| 45 |
+
@authorized
|
| 46 |
def interApp():
|
| 47 |
return "<h1>WIP</h1>"
|
| 48 |
|
| 49 |
@app.route("/signup")
|
| 50 |
+
def signup():
|
| 51 |
if not allow_signups:
|
| 52 |
abort(404)
|
| 53 |
return render_template("signin.html")
|
| 54 |
|
| 55 |
@app.route("/login")
|
| 56 |
+
def login():
|
| 57 |
return render_template("login.html")
|
| 58 |
|
| 59 |
|
| 60 |
+
|
| 61 |
@app.post("/api/signup")
|
| 62 |
def signupAPI():
|
| 63 |
error = None
|
|
|
|
| 72 |
.insert(dbData)
|
| 73 |
.execute()
|
| 74 |
)
|
| 75 |
+
return dbResponse, 200
|
| 76 |
+
"""
|
| 77 |
response = dbResponse["data"][0]
|
| 78 |
+
return make_response(response), 200"""
|
| 79 |
|
| 80 |
@app.post("/api/login")
|
| 81 |
def loginAPI():
|
|
|
|
| 105 |
return jwtPass[1], 401
|
| 106 |
|
| 107 |
|
| 108 |
+
|
| 109 |
@app.errorhandler(404)
|
| 110 |
def not_found(e):
|
| 111 |
return render_template("404.html")
|