Refactor onCreateUser hook