# Path: mass_flask_core/models/api_key.py
# class UserAPIKey(APIKey):
#     user = ReferenceField(User, required=True)
# 
#     @staticmethod
#     def get_or_create(user):
#         api_key = UserAPIKey.objects(user=user.id).first()
#         if not api_key:
#             api_key = UserAPIKey(user=user.id)
#             api_key.save()
#         return api_key
# 
#     @property
#     def referenced_entity(self):
#         return self.user
# 
# Path: mass_flask_webui/config.py



from flask import render_template
from flask_modular_auth import current_authenticated_entity, privilege_required, RolePrivilege
from mass_flask_core.models import UserAPIKey
from mass_flask_webui.config import webui_blueprint



@webui_blueprint.route('/profile/', methods=['GET'])
@privilege_required(RolePrivilege('user'))
def profile():

# Path: mass_flask_core/models/api_key.py
# class UserAPIKey(APIKey):
#     user = ReferenceField(User, required=True)
# 
#     @staticmethod
#     def get_or_create(user):
#         api_key = UserAPIKey.objects(user=user.id).first()
#         if not api_key:
#             api_key = UserAPIKey(user=user.id)
#             api_key.save()
#         return api_key
# 
#     @property
#     def referenced_entity(self):
#         return self.user
# 
# Path: mass_flask_webui/config.py



# Path: mass_flask_webui/views/profile.py
from flask import render_template
from flask_modular_auth import current_authenticated_entity, privilege_required, RolePrivilege
from mass_flask_core.models import UserAPIKey
from mass_flask_webui.config import webui_blueprint




@webui_blueprint.route('/profile/', methods=['GET'])
@privilege_required(RolePrivilege('user'))
def profile():

    api_key = UserAPIKey.get_or_create(current_authenticated_entity).generate_auth_token()