Fix the null pointer exception when login with invalid credentials