diff --git a/src/app.py b/src/app.py index b58c246..f1e2e3c 100644 --- a/src/app.py +++ b/src/app.py @@ -15,7 +15,7 @@ from marshm import ma from healthchecks import health_database_status from resources import SignupApi, LoginApi, UsersApi, UserParameterApi, CreateIngestResource, CreateEncodeResource, \ CreateRestreamResource, ManipulateStreamResource, GetAllStreamResources, ModifyEncodeResource, \ - ModifyIngressResource, ModifyRestreamResource, CoordModifyResource + ModifyIngressResource, ModifyRestreamResource, CoordModifyResource, MeApi """ Main Flask RESTful API @@ -51,6 +51,7 @@ jwtman.init_app(app) api.add_resource(SignupApi, '/api/auth/signup') api.add_resource(LoginApi, '/api/auth/login') +api.add_resource(MeApi, '/api/auth/me') api.add_resource(UsersApi, '/api/users') api.add_resource(UserParameterApi, '/api/users/') api.add_resource(CreateIngestResource, '/api/objects/streamerobjects/ingest') diff --git a/src/resources.py b/src/resources.py index df42084..9a26c25 100644 --- a/src/resources.py +++ b/src/resources.py @@ -99,6 +99,20 @@ class LoginApi(Resource): return {'token': access_token}, 200 +class MeApi(Resource): + """ + See: https://swagger.kmlabz.com/?urls.primaryName=videON%20Backend#/backend/logon + """ + + usermetadataschema = UserMetadataSchema(many=False) + + def post(self): + username = get_jwt_identity() + # username = "jozska" + user = VideonUser.query.filter_by(name=username).first_or_404() + return self.usermetadataschema.dump(user), 200 + + class UsersApi(Resource): """ See: https://swagger.kmlabz.com/?urls.primaryName=videON%20Backend#/backend/getall