Move onAuthenticated XAUTHORITY generation to the helper

This avoids it being created as root and then chown'd.