From 027139279aa0e83c123ba26139d84505f1d4af90 Mon Sep 17 00:00:00 2001 From: Fulgen301 Date: Sun, 16 Sep 2018 16:58:21 +0200 Subject: Use sqlalchemy as backend, implement JWT authentication, add uploading, commenting and voting --- routes/auth.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'routes/auth.py') diff --git a/routes/auth.py b/routes/auth.py index a34aaa5..934abc7 100644 --- a/routes/auth.py +++ b/routes/auth.py @@ -14,7 +14,7 @@ from ..helpers import * -@route("/api/auth", method="POST") +@post("/api/auth/register") def post_auth_new(): session = DBSession() try: @@ -30,4 +30,10 @@ def post_auth_new(): except db.orm.exc.NoResultFound: session.add(User(name=username, hash=hash)) session.commit() - return HTTPResponse(status=201) + return HTTPResponse(status=303, headers={"Location" : "/api/auth"}) + +@get("/api/auth") +@jwt_auth_required +def get_auth(): + return request.get_user() + -- cgit v1.2.3-54-g00ecf