
{"id":320808,"date":"2025-08-15T15:13:20","date_gmt":"2025-08-15T07:13:20","guid":{"rendered":"https:\/\/tzuchiculture.org\/forgotpwd\/"},"modified":"2025-09-26T18:21:48","modified_gmt":"2025-09-26T10:21:48","slug":"en-forgotpwd","status":"publish","type":"page","link":"https:\/\/culture.daaimobile.org\/en\/en-forgotpwd\/","title":{"rendered":"forgotpwd"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; theme_builder_area=&#8221;post_content&#8221; _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; custom_margin=&#8221;0px|0px|0px|0px|false|false&#8221; custom_padding=&#8221;0px|0px|0px|0px|false|false&#8221; hover_enabled=&#8221;0&#8243; sticky_enabled=&#8221;0&#8243; da_is_popup=&#8221;off&#8221; da_exit_intent=&#8221;off&#8221; da_has_close=&#8221;on&#8221; da_alt_close=&#8221;off&#8221; da_dark_close=&#8221;off&#8221; da_not_modal=&#8221;on&#8221; da_is_singular=&#8221;off&#8221; da_with_loader=&#8221;off&#8221; da_has_shadow=&#8221;on&#8221; da_disable_devices=&#8221;off|off|off&#8221;][et_pb_row _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; theme_builder_area=&#8221;post_content&#8221; custom_margin=&#8221;0px|auto|0px|auto|false|false&#8221; custom_padding=&#8221;0px|0px|0px|0px|false|false&#8221; hover_enabled=&#8221;0&#8243; sticky_enabled=&#8221;0&#8243;][et_pb_column _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; type=&#8221;4_4&#8243; theme_builder_area=&#8221;post_content&#8221;][et_pb_text _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; theme_builder_area=&#8221;post_content&#8221; hover_enabled=&#8221;0&#8243; sticky_enabled=&#8221;0&#8243;]    <div class=\"form-wrapper-c\">\n        <div class=\"title-wrapper\">\n          <div class=\"main-title-c\">\n            Forgot Password          <\/div>\n        <\/div>\n        <div class=\"custom-register-form\">\n\t\t    <div style=\"display:flex;justify-content:flex-end;font-size:1.2em;\">\n                <a href=\"\/en\/join-us\/\" class=\"login-link\" style=\"color:#000\">Back to Sign In<\/a>\t\t\t\t\t\t\t\t\t\n\t\t    <\/div>\n            <form method=\"post\" action=\"\" id=\"supabase-forgot-form\" >\n                <input type=\"hidden\" id=\"supabase_forgot_nonce\" name=\"supabase_forgot_nonce\" value=\"b91d1b7fe8\" \/><input type=\"hidden\" name=\"_wp_http_referer\" value=\"\/en\/wp-json\/wp\/v2\/pages\/320808\" \/>                <div id=\"step-1\">\n                    <div style=\"margin-bottom: 1em;\">\n\t        \t\t\t<label for=\"custom_email_phone\" class=\"form-label required\" style=\"display:block;\">Please enter your phone number or email<\/label>\n                        <div class=\"acf-custom-wrapper input-button-row\">\n                            <input type=\"text\" name=\"custom_email_phone\" id=\"custom_email_phone\" placeholder=\"\" \/>\n                        <\/div>\n \t    \t    \t\t<label id=\"verify-phone-label\" class=\"culture\" for=\"custom_email_phone\" >\n                            <span class=\"line\">Please enter your phone number<\/span>\n                            <span class=\"line\">(e.g., +8869xxxxxxxx) or email<\/span>\n                        <\/label>\n                        <button type=\"button\" id=\"send-otp\" class=\"culture btn-center\" style=\"display:none;\" >Send Verification Code<\/button>\n                    <\/div>\n                    <div id=\"otp-section\" style=\"margin-bottom:1em;display:none\">\n\t        \t    \t<label for=\"otp_code\" class=\"form-label\">Please enter the verification code<\/label>\n                        <div class=\"acf-custom-wrapper input-button-row\">\n                            <input type=\"text\" id=\"otp_code\" name=\"otp_code\" placeholder=\"Please enter the verification code\" maxlength=\"6\" \/>\n                        <\/div>\n                        <p id=\"otp-timer\" style=\"text-align:center; margin-top:0.5em; color: #888;\"><\/p>\n                    <\/div>\n                    <button type=\"button\" id=\"verify-btn\" class=\"culture btn-center btn-disabled\" disabled >Verify Verification Code<\/button>\n                <\/div>\n                <div id=\"new-password-section\" style=\"display:none;\">\n                    <div style=\"margin-bottom: 1em;\">\n\t        \t\t\t<label for=\"new_password\" class=\"form-label required\">Please enter a new password<\/label>\n                        <div style=\"position: relative;\">\n                            <input type=\"password\" id=\"new_password\" name=\"new_password\" placeholder=\"At least 8 characters, must include letters and numbers\" required style=\"width:100%; padding:10px; margin-bottom:1em;\" \/>\n                            <button type=\"button\" class=\"dashicons dashicons-visibility toggle-password\" onclick=\"togglePasswordVisibility('new_password', this)\" aria-label=\"\u5207\u63db\u5bc6\u78bc\u53ef\u898b\"\n                                style=\"position: absolute; top: 35%; right: 10px; transform: translateY(-50%);background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1;\"><\/button>\n                        <\/div>\n                    <\/div>\n                    <div style=\"margin-bottom: 1em;\">\n\t        \t\t\t<label for=\"new2_password\" class=\"form-label required\">Please re-enter the new password<\/label>\n                        <div style=\"position: relative;\">\n                            <input type=\"password\" id=\"new2_password\" name=\"new2_password\" placeholder=\"Please re-enter the new password\" required style=\"width:100%; padding:10px; margin-bottom:1em;\" \/>\n                            <button type=\"button\" class=\"dashicons dashicons-visibility toggle-password\" onclick=\"togglePasswordVisibility('new2_password', this)\" aria-label=\"\u5207\u63db\u5bc6\u78bc\u53ef\u898b\"\n                                style=\"position: absolute; top: 35%; right: 10px; transform: translateY(-50%);background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1;\"><\/button>\n                        <\/div>\n                    <\/div>\n                    <button type=\"submit\" id=\"reset_pw_submit\" class=\"culture btn-disabled\" disabled >Confirm<\/button>\n                <\/div>\n            <\/form>\n        <\/div>\n    <\/div>\n    <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@supabase\/supabase-js@2\"><\/script>\n    <script>\n        const client = supabase.createClient(\"https:\/\/jxnqpnlyieukvpehurgl.supabase.co\", \"sb_publishable_vb5kvkB5cSa-M6oq5iUDtQ_dJuDKZs5\");\n        const input = document.getElementById('custom_email_phone');\n        const sendOTPBtn = document.getElementById('send-otp');\n        const otpInput   = document.getElementById('otp_code');\n        const verifyBtn  = document.getElementById('verify-btn');\n        const setPwBtn = document.getElementById('reset_pw_submit');\n        const otpSection = document.getElementById('otp-section');\n        const newPw1 = document.getElementById('new_password');\n        const newPw2 = document.getElementById('new2_password');\n        const emailRe  = \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/;\n        const phoneRe  = \/^\\+\\d{10,15}$\/; \/\/ E.164\uff1a+8869...\n        let mode = 'email';\n  \n        function uiEmailMode(){\n            mode = 'email';\n            sendOTPBtn.style.display = 'none';\n            otpSection.style.display = 'none';\n            verifyBtn.textContent = 'Send reset email';\n            updateVerifyBtnState();\n        }\n  \n        function uiPhoneMode(){\n            mode = 'phone';\n            sendOTPBtn.style.display = '';\n            otpSection.style.display = 'none';\n            verifyBtn.textContent = 'Verify Verification Code';\n            updateVerifyBtnState();\n        }\n  \n        function updateVerifyBtnState(){\n            const v = (input.value || '').trim();\n            let enable = false;\n            if (mode === 'email') {\n                enable = emailRe.test(v);\n            } else {\n                enable = (otpSection.style.display !== 'none') && (otpInput.value.trim().length === 6);\n            }\n            verifyBtn.disabled = !enable;\n            verifyBtn.classList.toggle('btn-disabled', !enable);\n            verifyBtn.classList.toggle('btn-enabled',  enable);\n        }\n        otpInput.addEventListener('input', updateVerifyBtnState);\n        input.addEventListener('input', updateVerifyBtnState);\n\n        input.addEventListener('input', function(){\n            const v = this.value.trim();\n            if (phoneRe.test(v)) {\n                uiPhoneMode();\n            } else if (emailRe.test(v)) {\n                uiEmailMode();\n            } else {\n                uiEmailMode();\n            }\n        });\n\n        async function requestResetEmail(e) {\n            e.preventDefault();\n            const email = document.getElementById(\"custom_email_phone\").value.trim();\n            sendOTPBtn.disabled = true;\n            sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = sendOTPBtn.innerHTML;\n            sendOTPBtn.innerHTML = `<span class=\"spinner\"><\/span> Sending\u2026`;\n            const exists = await checkUserExists(email, 'email');\n            if (exists === null) {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            if (!exists) {\n                alert(\"<\/span> Account not found. Please check again or register.\");\n                sendOTPBtn.classList.remove(\"loading\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            try {\n                const { error } = await client.auth.resetPasswordForEmail(email, {\n                    redirectTo: window.location.origin + \"\/resetpwd\"\n                });\n                if (error) {\n                    alert(\"Failed to send password reset email. Please try again later:\" + error.message);\n                } else {\n                    alert(\"A password reset email has been sent to your inbox\");\n                    setTimeout(() => {\n                        window.location.href = \"\/signin\";\n                    }, 1500);\n                }\n            } catch (e) {\n                alert(\"Failed to send password reset email. Please try again later:\" + (e?.message || e));\n            } finally {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n            }\n        }\n\n        const AJAX_URL = \"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\";\n        async function checkUserExists(value, type) {\n          const sites = [\n            \"https:\/\/tzuchiculture.org\",\n            \"https:\/\/dharma.daai.tv\",\n            \/\/\"https:\/\/crm.daaimobile.org\"\n          ];\n          let errMsg = \"\";\n          for (let site of sites) {\n            try {\n              const apiUrl = site.replace(\/\\\/$\/, '') + '\/wp-json\/supabase-sso\/v1\/check_user_exists';\n              const res = await fetch(apiUrl, {\n                method: \"POST\",\n                headers: {\n                  \"Content-Type\": \"application\/json\",\n                },\n                body: JSON.stringify({ value, type })\n              });\n              if (!res.ok) {\n                errMsg += site + \" \u56de\u61c9\u5931\u6557:\" + res.status;\n                continue;\n              }\n              const json = await res.json();\n              if (json.success) {\n                if (json.data?.exists) {\n                  return true;\n                }\n                continue;\n              } else {\n                errMsg += `${site} \u56de\u61c9\u5931\u6557: ${json.data?.message || '\u672a\u77e5\u932f\u8aa4'}\\n`;\n              }\n            } catch (err) {\n              errMsg += site + \" \u547c\u53eb\u5931\u6557:\" + (err.message || err);\n              continue;\n            }\n          }\n          if(errMsg != \"\") {\n            alert(\"\u6aa2\u67e5\u5e33\u865f\u5931\u6557\uff1a\\n\" + errMsg);\n            return null;\n          } else {\n            return false;\n          }\n        }\n        async function sendOtp() {\n            const phone = document.getElementById(\"custom_email_phone\").value.trim();\n            if (!phone.match(\/^\\+\\d{10,15}$\/)) {\n                alert(\"Please enter a valid international phone number\");\n                return;\n            }\n            sendOTPBtn.disabled = true;\n            sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = sendOTPBtn.innerHTML;\n            sendOTPBtn.innerHTML = `<span class=\"spinner\"><\/span> Sending\u2026`;\n            const exists = await checkUserExists(phone, 'phone');\n            if (exists === null) {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            if (!exists) {\n                alert(\"Account not found. Please check again or register.\");\n                sendOTPBtn.classList.remove(\"loading\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            const formData = new FormData();\n            formData.append('action', 'send_custom_otp_sms');\n            formData.append('phone', phone);\n            try {\n                const response = await fetch(AJAX_URL, {\n                    method: 'POST',\n                    body: formData\n                });\n    \n                const res = await response.json();\n                if (res.success) {\n                    alert(\"\u9a57\u8b49\u78bc\u5df2\u767c\u9001\uff01 verification code has been sent.\");\n                    document.getElementById(\"otp-section\").style.display = \"block\";\n                } else {\n                    alert(\"\u767c\u9001\u5931\u6557\uff1a\" + (res.message || res.data || \"\u672a\u77e5\u932f\u8aa4\"));\n                }\n            } catch (error) {\n                alert(\"Failed to send, please try again later\");\n            } finally {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n            }\n        }\n\n        async function verifyOtp() {\n            const phone = input.value.trim();\n            const code = document.getElementById(\"otp_code\").value.trim();\n\n            const formData = new FormData();\n            formData.append('action', 'verify_otp');\n            formData.append('phone', phone);\n            formData.append('otp', code);\n            verifyBtn.disabled = true;\n            verifyBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = verifyBtn.innerHTML;\n            verifyBtn.innerHTML = `\n                <span class=\"spinner\"><\/span> Processing\u2026            `;\n    \n            try {\n                const response = await fetch(AJAX_URL, {\n                    method: 'POST',\n                    body: formData\n                });\n    \n                const res = await response.json();\n                if (res.success) {\n                    alert(\"\u624b\u6a5f\u9a57\u8b49\u6210\u529f\uff0c\u8acb\u8a2d\u5b9a\u65b0\u5bc6\u78bc Successfully verified, please set a new password.\");\n                    document.getElementById(\"new-password-section\").style.display = \"block\";\n                } else {\n                    alert(\"\u9a57\u8b49\u5931\u6557\uff1a\" + (res.message || \"\u672a\u77e5\u932f\u8aa4\"));\n                }\n            } catch (error) {\n                alert(\"Verification failed, please try again later\");\n            } finally {\n                verifyBtn.disabled = false;\n                verifyBtn.classList.remove(\"loading\", \"btn-disabled\");\n                verifyBtn.innerHTML = originalText;\n            }\n        }\n\n        sendOTPBtn.addEventListener('click', sendOtp);\n        verifyBtn.addEventListener('click', function(e){\n          if (mode === 'email') requestResetEmail(e);\n          else verifyOtp();\n        });\n\n        const CHANGE_PHONE_PWD_NONCE = \"0779701575\";\n        async function setNewPassword() {\n            const password  = newPw1.value.trim();\n            const password2 = newPw2.value.trim();\n            const phone     = (input?.value || \"\").trim();\n          \n            \/\/ \u57fa\u672c\u6aa2\u67e5\n            if (!password || !password2 || password !== password2) {\n                alert(\"Please make sure both password fields are filled in and match.\");\n                return;\n            }\n            if (password.length < 8 || !\/[A-Za-z]\/.test(password) || !\/\\d\/.test(password)) {\n                alert(\"Password must be at least 8 characters and include both letters and numbers.\");\n                return;\n            }\n            setPwBtn.disabled = true;\n            setPwBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = setPwBtn.innerHTML;\n            setPwBtn.innerHTML = `\n                <span class=\"spinner\"><\/span> Processing\u2026            `;\n            const formData = new FormData();\n            formData.append('action', 'change_phone_password');\n            formData.append('nonce', CHANGE_PHONE_PWD_NONCE);\n            formData.append('phone', phone);\n            formData.append('password', password);\n        \n            try {\n                const res = await fetch(AJAX_URL, {\n                    method: 'POST',\n                    body: formData\n                });\n                const result = await res.json();\n                if (result.success) {\n                    alert(\"Password updated successfully. Please sign in again.\");\n                    window.location.href = \"\/en\/join-us\/\";\n                } else {\n                    alert(\"Password update failed:\" + (result.data.message || \"\u672a\u77e5\u932f\u8aa4\"));\n                    setPwBtn.disabled = false;\n                    setPwBtn.classList.remove(\"loading\", \"btn-disabled\");\n                    setPwBtn.innerHTML = originalText;\n                    return;\n                }\n            } catch (e) {\n                alert(\"Password update failed:\" + (e?.message || e));\n                \/\/setPwBtn.disabled = false;\n            } finally {\n                setPwBtn.disabled = false;\n                setPwBtn.classList.remove(\"loading\", \"btn-disabled\");\n                setPwBtn.innerHTML = originalText;\n            }\n        }\n        function updateSetPwState(){\n            const ok = newPw1.value.trim().length >= 8 &&\n                       \/[A-Za-z]\/.test(newPw1.value) &&\n                       \/\\d\/.test(newPw1.value) &&\n                       (newPw1.value === newPw2.value);\n            setPwBtn.disabled = !ok;\n            setPwBtn.classList.toggle('btn-disabled', !ok);\n            setPwBtn.classList.toggle('btn-enabled',  ok);\n        }\n        newPw1.addEventListener('input', updateSetPwState);\n        newPw2.addEventListener('input', updateSetPwState);\n        setPwBtn.addEventListener('click', setNewPassword);\n\n        function togglePasswordVisibility(fieldId, toggleButton) {\n            const input = document.getElementById(fieldId);\n            const visibleClass = 'dashicons-visibility';\n            const hiddenClass = 'dashicons-hidden';\n        \n            if (input.type === 'password') {\n                input.type = 'text';\n                toggleButton.classList.remove(visibleClass);\n                toggleButton.classList.add(hiddenClass);\n            } else {\n                input.type = 'password';\n                toggleButton.classList.remove(hiddenClass);\n                toggleButton.classList.add(visibleClass);\n            }\n        }\n    <\/script>\n    [\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"    <div class=\"form-wrapper-c\">\n        <div class=\"title-wrapper\">\n          <div class=\"main-title-c\">\n            Forgot Password          <\/div>\n        <\/div>\n        <div class=\"custom-register-form\">\n\t\t    <div style=\"display:flex;justify-content:flex-end;font-size:1.2em;\">\n                <a href=\"\/en\/join-us\/\" class=\"login-link\" style=\"color:#000\">Back to Sign In<\/a>\t\t\t\t\t\t\t\t\t\n\t\t    <\/div>\n            <form method=\"post\" action=\"\" id=\"supabase-forgot-form\" >\n                <input type=\"hidden\" id=\"supabase_forgot_nonce\" name=\"supabase_forgot_nonce\" value=\"b91d1b7fe8\" \/><input type=\"hidden\" name=\"_wp_http_referer\" value=\"\/en\/wp-json\/wp\/v2\/pages\/320808\" \/>                <div id=\"step-1\">\n                    <div style=\"margin-bottom: 1em;\">\n\t        \t\t\t<label for=\"custom_email_phone\" class=\"form-label required\" style=\"display:block;\">Please enter your phone number or email<\/label>\n                        <div class=\"acf-custom-wrapper input-button-row\">\n                            <input type=\"text\" name=\"custom_email_phone\" id=\"custom_email_phone\" placeholder=\"\" \/>\n                        <\/div>\n \t    \t    \t\t<label id=\"verify-phone-label\" class=\"culture\" for=\"custom_email_phone\" >\n                            <span class=\"line\">Please enter your phone number<\/span>\n                            <span class=\"line\">(e.g., +8869xxxxxxxx) or email<\/span>\n                        <\/label>\n                        <button type=\"button\" id=\"send-otp\" class=\"culture btn-center\" style=\"display:none;\" >Send Verification Code<\/button>\n                    <\/div>\n                    <div id=\"otp-section\" style=\"margin-bottom:1em;display:none\">\n\t        \t    \t<label for=\"otp_code\" class=\"form-label\">Please enter the verification code<\/label>\n                        <div class=\"acf-custom-wrapper input-button-row\">\n                            <input type=\"text\" id=\"otp_code\" name=\"otp_code\" placeholder=\"Please enter the verification code\" maxlength=\"6\" \/>\n                        <\/div>\n                        <p id=\"otp-timer\" style=\"text-align:center; margin-top:0.5em; color: #888;\"><\/p>\n                    <\/div>\n                    <button type=\"button\" id=\"verify-btn\" class=\"culture btn-center btn-disabled\" disabled >Verify Verification Code<\/button>\n                <\/div>\n                <div id=\"new-password-section\" style=\"display:none;\">\n                    <div style=\"margin-bottom: 1em;\">\n\t        \t\t\t<label for=\"new_password\" class=\"form-label required\">Please enter a new password<\/label>\n                        <div style=\"position: relative;\">\n                            <input type=\"password\" id=\"new_password\" name=\"new_password\" placeholder=\"At least 8 characters, must include letters and numbers\" required style=\"width:100%; padding:10px; margin-bottom:1em;\" \/>\n                            <button type=\"button\" class=\"dashicons dashicons-visibility toggle-password\" onclick=\"togglePasswordVisibility('new_password', this)\" aria-label=\"\u5207\u63db\u5bc6\u78bc\u53ef\u898b\"\n                                style=\"position: absolute; top: 35%; right: 10px; transform: translateY(-50%);background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1;\"><\/button>\n                        <\/div>\n                    <\/div>\n                    <div style=\"margin-bottom: 1em;\">\n\t        \t\t\t<label for=\"new2_password\" class=\"form-label required\">Please re-enter the new password<\/label>\n                        <div style=\"position: relative;\">\n                            <input type=\"password\" id=\"new2_password\" name=\"new2_password\" placeholder=\"Please re-enter the new password\" required style=\"width:100%; padding:10px; margin-bottom:1em;\" \/>\n                            <button type=\"button\" class=\"dashicons dashicons-visibility toggle-password\" onclick=\"togglePasswordVisibility('new2_password', this)\" aria-label=\"\u5207\u63db\u5bc6\u78bc\u53ef\u898b\"\n                                style=\"position: absolute; top: 35%; right: 10px; transform: translateY(-50%);background: none; border: none; cursor: pointer; font-size: 20px; line-height: 1;\"><\/button>\n                        <\/div>\n                    <\/div>\n                    <button type=\"submit\" id=\"reset_pw_submit\" class=\"culture btn-disabled\" disabled >Confirm<\/button>\n                <\/div>\n            <\/form>\n        <\/div>\n    <\/div>\n    <script src=\"https:\/\/cdn.jsdelivr.net\/npm\/@supabase\/supabase-js@2\"><\/script>\n    <script>\n        const client = supabase.createClient(\"https:\/\/jxnqpnlyieukvpehurgl.supabase.co\", \"sb_publishable_vb5kvkB5cSa-M6oq5iUDtQ_dJuDKZs5\");\n        const input = document.getElementById('custom_email_phone');\n        const sendOTPBtn = document.getElementById('send-otp');\n        const otpInput   = document.getElementById('otp_code');\n        const verifyBtn  = document.getElementById('verify-btn');\n        const setPwBtn = document.getElementById('reset_pw_submit');\n        const otpSection = document.getElementById('otp-section');\n        const newPw1 = document.getElementById('new_password');\n        const newPw2 = document.getElementById('new2_password');\n        const emailRe  = \/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$\/;\n        const phoneRe  = \/^\\+\\d{10,15}$\/; \/\/ E.164\uff1a+8869...\n        let mode = 'email';\n  \n        function uiEmailMode(){\n            mode = 'email';\n            sendOTPBtn.style.display = 'none';\n            otpSection.style.display = 'none';\n            verifyBtn.textContent = 'Send reset email';\n            updateVerifyBtnState();\n        }\n  \n        function uiPhoneMode(){\n            mode = 'phone';\n            sendOTPBtn.style.display = '';\n            otpSection.style.display = 'none';\n            verifyBtn.textContent = 'Verify Verification Code';\n            updateVerifyBtnState();\n        }\n  \n        function updateVerifyBtnState(){\n            const v = (input.value || '').trim();\n            let enable = false;\n            if (mode === 'email') {\n                enable = emailRe.test(v);\n            } else {\n                enable = (otpSection.style.display !== 'none') && (otpInput.value.trim().length === 6);\n            }\n            verifyBtn.disabled = !enable;\n            verifyBtn.classList.toggle('btn-disabled', !enable);\n            verifyBtn.classList.toggle('btn-enabled',  enable);\n        }\n        otpInput.addEventListener('input', updateVerifyBtnState);\n        input.addEventListener('input', updateVerifyBtnState);\n\n        input.addEventListener('input', function(){\n            const v = this.value.trim();\n            if (phoneRe.test(v)) {\n                uiPhoneMode();\n            } else if (emailRe.test(v)) {\n                uiEmailMode();\n            } else {\n                uiEmailMode();\n            }\n        });\n\n        async function requestResetEmail(e) {\n            e.preventDefault();\n            const email = document.getElementById(\"custom_email_phone\").value.trim();\n            sendOTPBtn.disabled = true;\n            sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = sendOTPBtn.innerHTML;\n            sendOTPBtn.innerHTML = `<span class=\"spinner\"><\/span> Sending\u2026`;\n            const exists = await checkUserExists(email, 'email');\n            if (exists === null) {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            if (!exists) {\n                alert(\"<\/span> Account not found. Please check again or register.\");\n                sendOTPBtn.classList.remove(\"loading\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            try {\n                const { error } = await client.auth.resetPasswordForEmail(email, {\n                    redirectTo: window.location.origin + \"\/resetpwd\"\n                });\n                if (error) {\n                    alert(\"Failed to send password reset email. Please try again later:\" + error.message);\n                } else {\n                    alert(\"A password reset email has been sent to your inbox\");\n                    setTimeout(() => {\n                        window.location.href = \"\/signin\";\n                    }, 1500);\n                }\n            } catch (e) {\n                alert(\"Failed to send password reset email. Please try again later:\" + (e?.message || e));\n            } finally {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n            }\n        }\n\n        const AJAX_URL = \"https:\/\/culture.daaimobile.org\/wp-admin\/admin-ajax.php\";\n        async function checkUserExists(value, type) {\n          const sites = [\n            \"https:\/\/tzuchiculture.org\",\n            \"https:\/\/dharma.daai.tv\",\n            \/\/\"https:\/\/crm.daaimobile.org\"\n          ];\n          let errMsg = \"\";\n          for (let site of sites) {\n            try {\n              const apiUrl = site.replace(\/\\\/$\/, '') + '\/wp-json\/supabase-sso\/v1\/check_user_exists';\n              const res = await fetch(apiUrl, {\n                method: \"POST\",\n                headers: {\n                  \"Content-Type\": \"application\/json\",\n                },\n                body: JSON.stringify({ value, type })\n              });\n              if (!res.ok) {\n                errMsg += site + \" \u56de\u61c9\u5931\u6557:\" + res.status;\n                continue;\n              }\n              const json = await res.json();\n              if (json.success) {\n                if (json.data?.exists) {\n                  return true;\n                }\n                continue;\n              } else {\n                errMsg += `${site} \u56de\u61c9\u5931\u6557: ${json.data?.message || '\u672a\u77e5\u932f\u8aa4'}\\n`;\n              }\n            } catch (err) {\n              errMsg += site + \" \u547c\u53eb\u5931\u6557:\" + (err.message || err);\n              continue;\n            }\n          }\n          if(errMsg != \"\") {\n            alert(\"\u6aa2\u67e5\u5e33\u865f\u5931\u6557\uff1a\\n\" + errMsg);\n            return null;\n          } else {\n            return false;\n          }\n        }\n        async function sendOtp() {\n            const phone = document.getElementById(\"custom_email_phone\").value.trim();\n            if (!phone.match(\/^\\+\\d{10,15}$\/)) {\n                alert(\"Please enter a valid international phone number\");\n                return;\n            }\n            sendOTPBtn.disabled = true;\n            sendOTPBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = sendOTPBtn.innerHTML;\n            sendOTPBtn.innerHTML = `<span class=\"spinner\"><\/span> Sending\u2026`;\n            const exists = await checkUserExists(phone, 'phone');\n            if (exists === null) {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            if (!exists) {\n                alert(\"Account not found. Please check again or register.\");\n                sendOTPBtn.classList.remove(\"loading\");\n                sendOTPBtn.innerHTML = originalText;\n                return;\n            }\n            const formData = new FormData();\n            formData.append('action', 'send_custom_otp_sms');\n            formData.append('phone', phone);\n            try {\n                const response = await fetch(AJAX_URL, {\n                    method: 'POST',\n                    body: formData\n                });\n    \n                const res = await response.json();\n                if (res.success) {\n                    alert(\"\u9a57\u8b49\u78bc\u5df2\u767c\u9001\uff01 verification code has been sent.\");\n                    document.getElementById(\"otp-section\").style.display = \"block\";\n                } else {\n                    alert(\"\u767c\u9001\u5931\u6557\uff1a\" + (res.message || res.data || \"\u672a\u77e5\u932f\u8aa4\"));\n                }\n            } catch (error) {\n                alert(\"Failed to send, please try again later\");\n            } finally {\n                sendOTPBtn.disabled = false;\n                sendOTPBtn.classList.remove(\"loading\", \"btn-disabled\");\n                sendOTPBtn.innerHTML = originalText;\n            }\n        }\n\n        async function verifyOtp() {\n            const phone = input.value.trim();\n            const code = document.getElementById(\"otp_code\").value.trim();\n\n            const formData = new FormData();\n            formData.append('action', 'verify_otp');\n            formData.append('phone', phone);\n            formData.append('otp', code);\n            verifyBtn.disabled = true;\n            verifyBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = verifyBtn.innerHTML;\n            verifyBtn.innerHTML = `\n                <span class=\"spinner\"><\/span> Processing\u2026            `;\n    \n            try {\n                const response = await fetch(AJAX_URL, {\n                    method: 'POST',\n                    body: formData\n                });\n    \n                const res = await response.json();\n                if (res.success) {\n                    alert(\"\u624b\u6a5f\u9a57\u8b49\u6210\u529f\uff0c\u8acb\u8a2d\u5b9a\u65b0\u5bc6\u78bc Successfully verified, please set a new password.\");\n                    document.getElementById(\"new-password-section\").style.display = \"block\";\n                } else {\n                    alert(\"\u9a57\u8b49\u5931\u6557\uff1a\" + (res.message || \"\u672a\u77e5\u932f\u8aa4\"));\n                }\n            } catch (error) {\n                alert(\"Verification failed, please try again later\");\n            } finally {\n                verifyBtn.disabled = false;\n                verifyBtn.classList.remove(\"loading\", \"btn-disabled\");\n                verifyBtn.innerHTML = originalText;\n            }\n        }\n\n        sendOTPBtn.addEventListener('click', sendOtp);\n        verifyBtn.addEventListener('click', function(e){\n          if (mode === 'email') requestResetEmail(e);\n          else verifyOtp();\n        });\n\n        const CHANGE_PHONE_PWD_NONCE = \"0779701575\";\n        async function setNewPassword() {\n            const password  = newPw1.value.trim();\n            const password2 = newPw2.value.trim();\n            const phone     = (input?.value || \"\").trim();\n          \n            \/\/ \u57fa\u672c\u6aa2\u67e5\n            if (!password || !password2 || password !== password2) {\n                alert(\"Please make sure both password fields are filled in and match.\");\n                return;\n            }\n            if (password.length < 8 || !\/[A-Za-z]\/.test(password) || !\/\\d\/.test(password)) {\n                alert(\"Password must be at least 8 characters and include both letters and numbers.\");\n                return;\n            }\n            setPwBtn.disabled = true;\n            setPwBtn.classList.add(\"loading\", \"btn-disabled\");\n            const originalText = setPwBtn.innerHTML;\n            setPwBtn.innerHTML = `\n                <span class=\"spinner\"><\/span> Processing\u2026            `;\n            const formData = new FormData();\n            formData.append('action', 'change_phone_password');\n            formData.append('nonce', CHANGE_PHONE_PWD_NONCE);\n            formData.append('phone', phone);\n            formData.append('password', password);\n        \n            try {\n                const res = await fetch(AJAX_URL, {\n                    method: 'POST',\n                    body: formData\n                });\n                const result = await res.json();\n                if (result.success) {\n                    alert(\"Password updated successfully. Please sign in again.\");\n                    window.location.href = \"\/en\/join-us\/\";\n                } else {\n                    alert(\"Password update failed:\" + (result.data.message || \"\u672a\u77e5\u932f\u8aa4\"));\n                    setPwBtn.disabled = false;\n                    setPwBtn.classList.remove(\"loading\", \"btn-disabled\");\n                    setPwBtn.innerHTML = originalText;\n                    return;\n                }\n            } catch (e) {\n                alert(\"Password update failed:\" + (e?.message || e));\n                \/\/setPwBtn.disabled = false;\n            } finally {\n                setPwBtn.disabled = false;\n                setPwBtn.classList.remove(\"loading\", \"btn-disabled\");\n                setPwBtn.innerHTML = originalText;\n            }\n        }\n        function updateSetPwState(){\n            const ok = newPw1.value.trim().length >= 8 &&\n                       \/[A-Za-z]\/.test(newPw1.value) &&\n                       \/\\d\/.test(newPw1.value) &&\n                       (newPw1.value === newPw2.value);\n            setPwBtn.disabled = !ok;\n            setPwBtn.classList.toggle('btn-disabled', !ok);\n            setPwBtn.classList.toggle('btn-enabled',  ok);\n        }\n        newPw1.addEventListener('input', updateSetPwState);\n        newPw2.addEventListener('input', updateSetPwState);\n        setPwBtn.addEventListener('click', setNewPassword);\n\n        function togglePasswordVisibility(fieldId, toggleButton) {\n            const input = document.getElementById(fieldId);\n            const visibleClass = 'dashicons-visibility';\n            const hiddenClass = 'dashicons-hidden';\n        \n            if (input.type === 'password') {\n                input.type = 'text';\n                toggleButton.classList.remove(visibleClass);\n                toggleButton.classList.add(hiddenClass);\n            } else {\n                input.type = 'password';\n                toggleButton.classList.remove(hiddenClass);\n                toggleButton.classList.add(visibleClass);\n            }\n        }\n    <\/script>\n    \n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","pgc_sgb_lightbox_settings":"","footnotes":"","_links_to":"","_links_to_target":""},"dipi_cpt_category":[],"class_list":["post-320808","page","type-page","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages\/320808","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/comments?post=320808"}],"version-history":[{"count":5,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages\/320808\/revisions"}],"predecessor-version":[{"id":320813,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/pages\/320808\/revisions\/320813"}],"wp:attachment":[{"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/media?parent=320808"}],"wp:term":[{"taxonomy":"dipi_cpt_category","embeddable":true,"href":"https:\/\/culture.daaimobile.org\/en\/wp-json\/wp\/v2\/dipi_cpt_category?post=320808"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}