How to throw an unauthorized message based on user lookup in database?

I currently have built a dash app that has no authentication and works as expected. However, I am now trying to integrate the app via an iframe to an existing system that we have direct database access to and want to check the database and disallow access if user isn’t found.

I have tried using the dash-auth “basicAuth” and edit the “is_authorized” function to query the database and throw a 403 Unauthorized message is the user cannot be found. I did get this to work on the initial pageload but then all the “_reload-hash” were throwing errors after inital pageload. As well, the application is multi page which may present other issues as I have been reading about the authorization module.

Is there a better way to do this? Any suggestions would be super helpful!

As well, let me know if I can help provide some additional details. Thanks!