Authentication window not dismissed

Hi,
I've fixed a problem with the authentication window not dismissed even when the authorization was granted, and I've modified the way to understand if the authentication process has ended.

Stefano