I am trying to implement custom security for my website outside of the implemented wix roles/permissions. The reason I want my own is because I created my own members database and want to be able to assign permission levels within this database. I have a secondary database for access roles with permission levels. Right now, when an admin page is loaded, my code calls a backend function that then checks if the user has the correct permission levels which works just fine. Also, in case of a malicious user changing the front in code to no longer check for access, all database calls are checked in the backend for permissions as well. My main problem is getting a page to stop loading for someone who doesn't have access. I tried running a wix.location.tourl() function as soon as the users authenticity is known but this call takes too long and the page is already presenting itself to the user (it's not showing anything important, I just don't want it to show anything at all). I have also tried immediately presenting a lightbox but this does not load in time either. Is there any way that I can check from my own database to know the user isn't allowed in a location and redirect them or stop loading the current page before any GUI is presented?
Thank you for your time,