I would like to use wix-users module APIs on my site. To control user access to specific page I added wixUsers.promptLogin() in $w.onReady event init function, which seems to works well.
As well I was able to perform logout correctly using wixUsers.logout() in button onClick event handler.
However I want to ensure that user account is also logged out once they close the page.
As I may see right now, user remains logged in after page is closed and reopened.
To workaround it, I used wix-storage session object:
(1) to check if previous session still exists when page starts loading;
(2) to logout user if (1) is false (page was closed previously);
(3) run wixUsers.promptLogin() again.
However this method has some side effects, one of them is that page starts rendering and being visible, and only then login screen appears (I suppose it happens because logout runs asynchronously).
-Is there any event I may use when page is being closed to perform logout?
-Is it possible to recognize user inactivity for specified time and suggest / perform logout?