Added logout functionality when authentication required