Fixed bug causing the authentication occur twice.