fix bugs in authentication.