merge many things in auth.c