fix authentication and deauthentication