add register and auth logic function