copy half the code from an old project for auth