Updated the code for handling authentication.