Multiple Auth attempts on MongoDB v6

Hello

I am running a MongoDB v6 replica set on a Ubuntu Jammy server (upgraded from MongoDB v4). For legacy reasons I am planning to use the old mongo cli tool with my upgraded MongoDB instance and also have a lot of existing/legacy scripts to do certain tasks. Many of these scripts do a login at the top like so:
db.auth(username,password)

With MongoDB v6 this command fails with an error:
"Error: Each client connection may only be authenticated once. Previously authenticated as: "

My question is how can I work around above error? I understand that mongo cli is deprecated however if I switch to mongosh tool then I have to take care of updating my scripts. For example the auth() function now returns a json response rather than a plain integer value.

Regards
Ani