24 lines
807 B
Python
24 lines
807 B
Python
from flask import Blueprint, request, jsonify
|
|
from datetime import datetime
|
|
from geruecht.controller import accesTokenController, userController
|
|
from geruecht.model import MONEY, GASTRO
|
|
|
|
vorstand = Blueprint("vorstand", __name__)
|
|
|
|
@vorstand.route("/sm/addUser", methods=['POST', 'GET'])
|
|
def _addUser():
|
|
|
|
if request.method == 'GET':
|
|
return "<h1>HEllo World</h1>"
|
|
|
|
token = request.headers.get("Token")
|
|
accToken = accesTokenController.validateAccessToken(token, [MONEY, GASTRO])
|
|
if accToken:
|
|
data = request.get_json()
|
|
user = data['user']
|
|
date = datetime.utcfromtimestamp(int(data['date']))
|
|
userController.addWorker(user['username'], date)
|
|
|
|
print(data)
|
|
return jsonify({"date": date})
|
|
return jsonify({"error": "permission denied"}), 401 |