moved code related to auth to separated module