Added the logout functionality and authentication mechanism