modified endpoint and added login/logout logic