Error checkings in auth functions