28 lines
709 B
Python
28 lines
709 B
Python
"""
|
|
Endpoinds to help user determine identity
|
|
"""
|
|
|
|
__author__ = '@tormakris'
|
|
__copyright__ = "Copyright 2020, onSpot Team"
|
|
__module_name__ = "meapi"
|
|
__version__text__ = "1"
|
|
|
|
from flask import request, current_app, abort
|
|
from flask_restful import Resource
|
|
|
|
from flaskaddons.fred import flaskred
|
|
|
|
|
|
class MeApi(Resource):
|
|
"""
|
|
See: https://swagger.kmlabz.com/?urls.primaryName=onSpot%20Backend#/backend/currentUser
|
|
"""
|
|
|
|
def get(self):
|
|
try:
|
|
currusername = flaskred.get(request.headers.get('Authorization')).decode('UTF-8')
|
|
except Exception as e:
|
|
current_app.logger.warning(e)
|
|
abort(401, "unauthorized")
|
|
return {"name": currusername}, 200
|