diff --git a/dash_auth/current_user_hook/__init__.py b/dash_auth/current_user_hook/__init__.py new file mode 100644 index 0000000..01450b3 --- /dev/null +++ b/dash_auth/current_user_hook/__init__.py @@ -0,0 +1,11 @@ +import flask + +from dash import hooks + +@hooks.custom_data("user") +def custom_data_func(_ctx): + try: + cu = flask.session["user"] + except AttributeError as e: + cu = {} + return cu diff --git a/setup.py b/setup.py index 8ba759b..9086418 100644 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ }, python_requires=">=3.8", include_package_data=True, + entrypoints={"dash_hooks": ["current_user_hook = current_user_hook"]}, url='https://plotly.com/dash', classifiers=[ 'Development Status :: 5 - Production/Stable',