Added handling of authentication and logout process