Registration js refactor