refactor user auth