refactor of user auth