implement login

This commit is contained in:
2021-06-12 13:24:26 +02:00
parent 3920183e0c
commit c33c08fe0a
10 changed files with 134 additions and 14 deletions

View File

@ -1,6 +1,7 @@
import os
from flask import make_response, request, send_file
from flask import jsonify, make_response, request, send_file
from ki.auth import auth
from ki.models import Language, Skill
from app import app
@ -64,6 +65,17 @@ def handle_icon_request(model, id, path):
def hello_world():
return "KI"
@app.route("/users/login", methods=["POST"])
def login():
username = request.json.get("username", "")
password = request.json.get("password", "")
token = auth(username, password)
if token is None:
return make_response({}, 403)
return make_response({"token": token.token})
@app.route("/skills")
def get_skills():