Hi, I am writing a simple electron “productivity” application (with a currently somewhat unfortunate name) that essentially just wraps a set of preloaded web apps in webviews. Very simply really.
Now I am struggling with sites that require basic authentication (I have a few admin sites that I need to monitor). The way I handled it in
so far is that
- upon receiving “login” the main process will cancel default handling and send a message “get-login-auth” to the renderer to retrieve login data. The auth callback is memorized.
- the renderer shows a login popup
- after entering the user data and pressing ok, a message “set-login-auth” is send to main
- main calls the memorized callback with the auth data.
- auth succeeded, everything’s cool
So that works. But cancelling login does not really work. What I tried is to check if there is a second “login” event for which no data was supplied (i.e. 3.+4. never happened) and in that case let the defaults apply. In that case however, I get another ‘did-finish-load’ event and the failed web view is gone. I’d rather have the web view show exactly what it would do if the defaults would have been in effect in the first place.
I.e.: How can I cancel the auth flow cleanly?