














{"id":231,"date":"2024-05-22T15:26:59","date_gmt":"2024-05-22T15:26:59","guid":{"rendered":"https:\/\/www.buddyupgo.com\/?page_id=231"},"modified":"2024-05-22T15:26:59","modified_gmt":"2024-05-22T15:26:59","slug":"login","status":"publish","type":"page","link":"https:\/\/staging.buddyupgo.com\/login\/","title":{"rendered":"Login"},"content":{"rendered":"<div class=\"buddyUpPjaxContainer\" data-buddyup-pjax-container=\"1\"><style>.hidden, .error-message {\n    display: none;\n}\n\ninput {\n    width: 100%;\n    display: block;\n}\n\nbody .buddyUpLoginTheme {\n    max-width: 550px;\n    margin: 0 auto;\n    padding: 2rem;\n    min-height: 430px;\n}\n\nbody.buddyup-login-pending {\n    overflow: hidden;\n}\n\n#buddyUpLoginWrapper .buddyUpPagesWrapper {\n    overflow: visible;\n    white-space: normal;\n}\n\n#buddyUpLoginWrapper .buddyUpErrorPageImage {\n    display: block;\n    width: min(400px, 100%);\n    max-width: 100%;\n    height: auto;\n}\n\n#buddyUpLoginWrapper .buddyUpPage:not(.hidden) {\n    display: block;\n    width: 100%;\n    white-space: normal;\n}\n\n.buddyUp form {\n    margin-bottom: 0;\n    position: relative;\n}\n\nh2 {\n    padding-top: 0;\n}\n\n.loginFormButtonGroup {\n    display: flex;\n    justify-content: space-between;\n    align-items: center;\n    gap: .5rem;\n}\n\n.loginFormButtonGroup > * {\n    width: auto;\n    margin: .5rem 0 0;\n}\n\n.buddyUpGoogleAuth {\n    display: flex;\n    flex-direction: column;\n    align-items: center;\n    width: 100%;\n    margin: .5rem 0;\n}\n\n.buddyUpGoogleButton {\n    display: flex;\n    justify-content: center;\n    width: 100%;\n    min-height: 44px;\n}\n\n.buddyUpGoogleStatus {\n    min-height: 1.25rem;\n    margin: .4rem 0 0;\n    color: #9c2f2f;\n    font-size: .9rem;\n    text-align: center;\n}\n\n.buddyUpAuthDivider {\n    display: flex;\n    align-items: center;\n    gap: .75rem;\n    margin: .85rem 0 1rem;\n    color: #666;\n    font-size: .86rem;\n}\n\n.buddyUpAuthDivider::before,\n.buddyUpAuthDivider::after {\n    content: '';\n    flex: 1;\n    height: 1px;\n    background: #d8d8d8;\n}\n\n.registerLink {\n    font-weight: bold;\n    color: var(--primary-color);\n}\n\n.registerLink:hover {\n    color: var(--primary-color);\n    opacity: .8;\n}\n\n.passwordInputWrapper {\n    position: relative;\n}\n\n.passwordInputWrapper input {\n    padding-right: 3rem;\n}\n\n.buddyUpLoginPendingOverlay {\n    position: fixed;\n    inset: 0;\n    z-index: 200000;\n    background: rgba(12, 14, 16, 0.58);\n    backdrop-filter: blur(2px);\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    padding: 1rem;\n    pointer-events: auto;\n    touch-action: none;\n}\n\n.buddyUpLoginPendingOverlay.hidden {\n    display: none;\n}\n.buddyUpLoginPendingModal {\n    min-width: min(90vw, 300px);\n    max-width: 360px;\n    border-radius: 16px;\n    background: #ffffff;\n    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);\n    padding: 1rem 1.1rem;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    gap: .75rem;\n}\n\n.buddyUpLoginPendingModal p {\n    margin: 0;\n    font-size: .96rem;\n    font-weight: 600;\n    color: #2a2a2a;\n}\n\n.buddyUpLoginSpinner {\n    width: 20px;\n    height: 20px;\n    border-radius: 50%;\n    border: 2px solid rgba(0, 0, 0, 0.2);\n    border-top-color: var(--primary-color);\n    animation: buddyUpLoginSpin .75s linear infinite;\n}\n\n#buddyUpLogMeIn.is-loading {\n    opacity: .92;\n}\n\n@keyframes buddyUpLoginSpin {\n    to {\n        transform: rotate(360deg);\n    }\n}\n\n#showPasswordButton {\n    position: absolute;\n    top: 50%;\n    transform: translateY(-50%);\n    right: 0;\n    width: 44px;\n    min-width: 44px;\n    height: 44px;\n    min-height: 44px;\n    margin: 0;\n    border: none;\n    padding: 0;\n    display: flex;\n    align-items: center;\n    justify-content: center;\n    font-size: .8rem;\n}\n\n#buddyUpLoginTab .buddyUpGoToNextPage,\n.buddyUpLinkButton {\n    min-height: 44px;\n    display: inline-flex;\n    align-items: center;\n}\n\n.buddyUpLinkButton {\n    appearance: none;\n    border: 0;\n    background: transparent;\n    color: var(--primary-color);\n    padding: .45rem 0;\n    font: inherit;\n    font-weight: 700;\n    text-decoration: underline;\n    cursor: pointer;\n}\n\n#buddyUpLogMeIn,\n#buddyUpSendForgotPwd {\n    min-height: 44px;\n}\n\n#showPasswordButton i {\n    padding-top: 2px;\n}\n\n@media (max-width: 400px){\n    .registerLink {\n        min-height: 44px;\n        display: flex;\n        align-items: center;\n        justify-content: center;\n    }\n}\n\n\n\/* Email Verify Message - Post Register *\/\n.buddyUpVerifyEmailModal {\n    max-width: 600px !important;\n}\n\n.buddyUpVerifyEmailModal .buddyUpModalIcon {\n    font-size: 4rem;\n    color: var(--primary-color);\n    margin-bottom: 1rem;\n}\n\n.buddyUpVerifyEmailModal button {\n    margin: .5rem 0;\n}\n\n.buddyUpVerifyEmailModal button[disabled=\"disabled\"] {\n    border: 2px solid #c4c4c4 !important;\n    background: #c4c4c4 !important;\n    color: #2E2E2E !important;\n}\n\n.buddyUpVerifyEmailModal #buddyUpEmailResendCountdown {\n    font-size: .9rem;\n    font-style: italic;\n}\n\n.buddyUpVerifyEmailModalVerifying {\n    max-width: 500px !important;\n}\n\n.buddyUpVerifyEmailModalVerifying .textHeading {\n    margin-bottom: .5rem;\n}\n\n.buddyUpVerifyEmailModalVerifying .buddyUpLoadingEl i,\n.buddyUpVerifyEmailModalVerifying .buddyUpModalIcon {\n    font-size: 2rem;\n    margin-bottom: 1rem;\n    color: var(--primary-color);\n}\n\n.buddyUpVerifyEmailModalVerifying p {\n    padding: 0;\n}\n<\/style>\n<div id=\"buddyUpLoginWrapper\" class=\"buddyUpLoginTheme hidden buddyUp\">\n    <div class=\"buddyUpPagesWrapper\">\n        <!-- Login Form -->\n        <img decoding=\"async\" src=\"https:\/\/staging.buddyupgo.com\/wp-content\/plugins\/buddyup\/img\/trailer-image.webp\" alt=\"BuddyUp illustration\" class=\"buddyUpErrorPageImage\" style=\"margin: 0 auto 2rem;\">\n        <form id=\"buddyUpLoginTab\" class=\" mainLoginContainer buddyUpPage form \">\n            <h2>Login<\/h2>\n            <div class=\"buddyUpLoginFormWrapper\">\n                <div class=\"loginForm\">\n                                            <div class=\"buddyUpGoogleAuth\">\n                            <div id=\"buddyUpGoogleLoginButton\" class=\"buddyUpGoogleButton\" aria-label=\"Sign in with Google\"><\/div>\n                            <p id=\"buddyUpGoogleLoginStatus\" class=\"buddyUpGoogleStatus\" aria-live=\"polite\"><\/p>\n                        <\/div>\n                        <div class=\"buddyUpAuthDivider\" role=\"separator\"><span>or sign in with email<\/span><\/div>\n                                        <div class=\"buddyup-input-group\">\n                        <label id=\"buddyup-emailLabel\" for=\"formEmail\" >Email<\/label>\n                        <input tabindex=\"0\" autocomplete=\"email\" type=\"email\" id=\"formEmail\" name=\"email\" inputmode=\"email\" placeholder=\" \" required \/>\n                        <div id=\"formEmailError\" class=\"error-message\">Please enter a valid email<\/div>\n                    <\/div>\n\n                    <div class=\"buddyup-input-group\">\n                        <label id=\"buddyup-pwLabel\" for=\"formPWD\" >Password<\/label>\n                        <div class=\"passwordInputWrapper\"><input tabindex=\"0\" autocomplete=\"current-password\" type=\"password\" id=\"formPWD\" name=\"password\" placeholder=\" \" required \/><button id=\"showPasswordButton\" aria-label=\"Show Password\" type=\"button\"><i class=\"fa fa-solid fa-eye fa-fw\"><\/i><\/button><\/div>\n                        <div id=\"formPWDError\" class=\"error-message\">Please enter a password<\/div>\n                    <\/div>\n\n                    <div id=\"formIncorrectInfo\" class=\"buddyUpErrorMessage hidden\">The information you entered is incorrect. Please try again.<\/div>\n                    \n                    <div style=\"text-align: right;\">\n                        <div style=\"margin-top: .5rem;\"><button type=\"button\" aria-label=\"Forgot your password?\" class=\"buddyUpGoToNextPage buddyUpLink buddyUpLinkButton\" data-next-page=\"buddyUpPwdTab\">Forgot your password?<\/button><\/div>\n                    <\/div>\n                    <div class=\"submitButtonWrapper\">\n                        <input type=\"submit\" value=\"Sign In\" role=\"button\" id=\"buddyUpLogMeIn\" aria-label=\"Login\" tabindex=\"0\" class=\"buddyUpButton1\">\n                    <\/div>\n                    \n                    <div style=\"text-align: center;\">\n                        <div>Don't have an account? <a aria-label=\"Create an account\" tabindex=\"0\" href=\"https:\/\/staging.buddyupgo.com\/register\/\" class=\"registerLink\">Create an account<\/a><\/div>\n                        <!-- <div>Don't have an account? <a aria-label=\"Create an account\" tabindex=\"0\" href=\"#\" class=\"registerLink buddyUpGoToNextPage\" data-next-page=\"buddyUpRegTab\">Create an account<\/a><\/div> -->\n                    <\/div>\n                <\/div>\n            <\/div>\n        <\/form>\n        \n        <!-- Password Reset Form -->\n        <form id=\"buddyUpPwdTab\" class=\"buddyUpPage pwdWrapper form hidden\">\n            <div class=\"contentFormRegister buddyUpLoginFormWrapper\">\n                <div id=\"forgotPwdSuccess\" class=\"successBackground\"><\/div>\n                <h2>Reset your password<\/h2>\n                <p>Enter the email address associated with your account and we'll send you an email with a link to reset your password.<\/p>\n                <div class=\"buddyup-input-group\">\n                    <label id=\"resetEmail\" for=\"forgotPWDEmail\" ><span class=\"bold\">Email<\/span><\/label>\n                    <input tabindex=\"0\" required autocomplete=\"email\" type=\"email\" id=\"forgotPWDEmail\" name=\"email\" inputmode=\"email\" placeholder=\" \"\/>\n                    \n                    <div id=\"forgotPWDEmailError\"class=\"error-message\">Please enter a valid email<\/div>\n                <\/div>\n                <div class=\"loginFormButtonGroup\">\n                    <button type=\"button\" aria-label=\"Login to your account\" class=\"buddyUpGoToNextPage buddyUpGoBack buddyUpLinkButton\" data-next-page=\"buddyUpLoginTab\">Back to Sign in<\/button>\n                    <input type=\"submit\" value=\"Send\" role=\"button\" id=\"buddyUpSendForgotPwd\" aria-label=\"Reset password\" tabindex=\"0\" class=\"submit_button_1 buddyUpButton1\">\n                <\/div>\n            <\/div>\n        <\/form>\n    <\/div>\n\n    <div id=\"buddyUpLoginPendingOverlay\" class=\"buddyUpLoginPendingOverlay hidden\" aria-live=\"polite\" aria-atomic=\"true\" role=\"status\">\n        <div class=\"buddyUpLoginPendingModal\" aria-hidden=\"true\">\n            <span class=\"buddyUpLoginSpinner\" aria-hidden=\"true\"><\/span>\n            <p>Signing you in...<\/p>\n        <\/div>\n    <\/div>\n<\/div>\n<script>\/***\n * Redirect if already logged in\n *\/\nconst buddyUpVerifyParams = new URLSearchParams(window.location.search || '');\nconst buddyUpHasEmailVerificationParams = buddyUpVerifyParams.has('user_id') && buddyUpVerifyParams.has('verification_id') && buddyUpVerifyParams.has('validation_token');\nconst buddyUpPostLoginRedirectKey = 'buddyup_post_login_redirect';\nlet buddyUpLoginRequestInFlight = false;\nlet buddyUpPendingGoogleCredential = '';\n\nfunction buddyUpSetLoginPendingState(isPending) {\n    const loginButton = document.getElementById('buddyUpLogMeIn');\n    const pendingEl = document.getElementById('buddyUpLoginPendingOverlay');\n\n    if (loginButton) {\n        if (isPending) {\n            loginButton.setAttribute('disabled', 'disabled');\n            loginButton.classList.add('is-loading');\n            loginButton.value = 'Signing In...';\n        } else {\n            loginButton.removeAttribute('disabled');\n            loginButton.classList.remove('is-loading');\n            loginButton.value = 'Sign In';\n        }\n    }\n\n    if (pendingEl) {\n        pendingEl.classList.toggle('hidden', !isPending);\n    }\n\n    document.body.classList.toggle('buddyup-login-pending', !!isPending);\n}\n\nbuddyUpSetLoginPendingState(false);\nwindow.addEventListener('pageshow', () => buddyUpSetLoginPendingState(false));\n\nfunction buddyUpConsumeStoredPostLoginDestination() {\n    const raw = (() => {\n        try {\n            return sessionStorage.getItem(buddyUpPostLoginRedirectKey)\n                || localStorage.getItem(buddyUpPostLoginRedirectKey)\n                || '';\n        } catch (e) {\n            return '';\n        }\n    })();\n\n    const value = String(raw || '').trim();\n    if (!value) return '';\n\n    try {\n        const parsed = new URL(value, window.location.origin);\n        if (parsed.origin !== window.location.origin) return '';\n        const resolved = `${parsed.pathname}${parsed.search}${parsed.hash}`;\n        try { sessionStorage.removeItem(buddyUpPostLoginRedirectKey); } catch (e) {}\n        try { localStorage.removeItem(buddyUpPostLoginRedirectKey); } catch (e) {}\n        return resolved || '';\n    } catch (e) {\n        return '';\n    }\n}\n\nfunction buddyUpPostLoginDestination() {\n    const storedDestination = buddyUpConsumeStoredPostLoginDestination();\n    if (storedDestination) return storedDestination;\n\n    if (window.buddyUpVariables && buddyUpVariables.for_me_link) return buddyUpVariables.for_me_link;\n    if (window.buddyUpVariables && buddyUpVariables.home_link) return buddyUpVariables.home_link;\n    if (window.buddyUpVariables && buddyUpVariables.account_link) return buddyUpVariables.account_link;\n    return '\/';\n}\nfunction buddyUpCacheBustPageUrl(url) {\n    try {\n        const parsed = new URL(url || '\/', window.location.origin);\n        if (parsed.origin !== window.location.origin) return url;\n        parsed.searchParams.set('buddyup_cb', String(Date.now()));\n        return `${parsed.pathname}${parsed.search}${parsed.hash}`;\n    } catch (e) {\n        return url;\n    }\n}\n\nfunction buddyUpLooksLikeAuthSessionError(message) {\n    const msg = String(message || '').toLowerCase();\n    if (!msg) return false;\n\n    return (\n        msg.includes('invalid user or token') ||\n        msg.includes('invalid user token') ||\n        msg.includes('authentication failed') ||\n        msg.includes('authentication required') ||\n        msg.includes('session expired') ||\n        msg.includes('user not found')\n    );\n}\n\n(async function(){\n    const loginWrapper = document.getElementById('buddyUpLoginWrapper');\n    if (loginWrapper) {\n        loginWrapper.classList.remove('hidden');\n    }\n\n    const cachedUser = BUDDYUP.getCurrentUser();\n    const hasLocalSession = !!(BUDDYUP && typeof BUDDYUP.hasAuthenticatedUser === 'function'\n        ? BUDDYUP.hasAuthenticatedUser(cachedUser)\n        : (cachedUser && cachedUser.id && cachedUser.user_token));\n\n    if (!hasLocalSession || buddyUpHasEmailVerificationParams) return;\n\n    Promise.resolve().then(async () => {\n        const authProbe = await BUDDYUP.apiRequest('account-get', {\n            id: cachedUser.id,\n            fields: 'id',\n            _force: true,\n            _cb: Date.now()\n        });\n\n        if (authProbe && authProbe.status === 'success') {\n            BUDDYUP.pjaxNavigate(buddyUpCacheBustPageUrl(buddyUpPostLoginDestination()));\n            return;\n        }\n\n        if (buddyUpLooksLikeAuthSessionError(authProbe && authProbe.message)) {\n            try { await BUDDYUP.logUserOut(); } catch (e) {}\n        }\n    }).catch(() => {});\n})();\n\n\nfunction buddyUpClearStaleAuthBeforeLogin() {\n    try { localStorage.removeItem('buddyup_user'); } catch (e) {}\n    try { sessionStorage.removeItem('buddyup_ssr_auth_sig'); } catch (e) {}\n    try {\n        if (BUDDYUP && typeof BUDDYUP.clearSsrAuthCookie === 'function') BUDDYUP.clearSsrAuthCookie();\n        if (BUDDYUP && typeof BUDDYUP.setClientAuthState === 'function') {\n            BUDDYUP.setClientAuthState({ logged_in: 0, user_id: 0, subscription_tier: 0 });\n        }\n    } catch (e) {}\n}\n\nfunction buddyUpExtractAuthenticatedUser(response) {\n    if (!response || typeof response !== 'object') return null;\n    if (response.user_token) return response;\n    if (response.data && typeof response.data === 'object' && response.data.user_token) return response.data;\n    return null;\n}\n\nasync function buddyUpFinishLoginIfAuthenticated(response) {\n    const responseUser = buddyUpExtractAuthenticatedUser(response);\n    if (!responseUser || !window.BUDDYUP || typeof BUDDYUP.setUser !== 'function') return false;\n\n    await Promise.resolve(BUDDYUP.setUser(responseUser)).catch(() => false);\n    const destination = buddyUpCacheBustPageUrl(buddyUpPostLoginDestination());\n    if (destination && destination !== `${window.location.pathname}${window.location.search}`) {\n        window.location.assign(destination);\n    } else {\n        window.location.reload();\n    }\n    return true;\n}\n\nfunction buddyUpGoogleStatus(message) {\n    const status = document.getElementById('buddyUpGoogleLoginStatus');\n    if (status) status.textContent = String(message || '');\n}\n\nasync function buddyUpHandleGoogleLogin(googleResponse) {\n    const credential = String(googleResponse && googleResponse.credential || '').trim();\n    if (!credential || buddyUpLoginRequestInFlight) return;\n\n    buddyUpLoginRequestInFlight = true;\n    buddyUpSetLoginPendingState(true);\n    buddyUpGoogleStatus('Verifying your Google account...');\n    buddyUpClearStaleAuthBeforeLogin();\n    let loginSucceeded = false;\n\n    try {\n        const response = await BUDDYUP.apiRequest('google-login', { credential: credential });\n        if (await buddyUpFinishLoginIfAuthenticated(response)) {\n            loginSucceeded = true;\n            return;\n        }\n\n        if (response && response.status === 'registration_required') {\n            const pending = {\n                credential: credential,\n                profile: response.google_profile || {},\n                expires_at: Date.now() + (50 * 60 * 1000),\n            };\n            try { sessionStorage.setItem('buddyup_google_registration', JSON.stringify(pending)); } catch (e) {}\n            buddyUpGoogleStatus('Google verified. Opening BuddyUp profile setup...');\n            const registerUrl = window.buddyUpVariables && buddyUpVariables.register_link\n                ? buddyUpVariables.register_link\n                : '\/register\/';\n            window.location.assign(registerUrl);\n            return;\n        }\n\n        if (response && response.status === 'link_password_required') {\n            buddyUpPendingGoogleCredential = credential;\n            const emailInput = document.getElementById('formEmail');\n            const passwordInput = document.getElementById('formPWD');\n            if (emailInput) {\n                emailInput.value = String(response.email || '');\n                emailInput.readOnly = true;\n            }\n            buddyUpGoogleStatus(response.message || 'Enter your BuddyUp password once to link Google.');\n            if (passwordInput) passwordInput.focus();\n            return;\n        }\n\n        buddyUpGoogleStatus(response && (response.message || response.data)\n            ? String(response.message || response.data)\n            : 'Google sign-in was not completed. Please try again.');\n    } catch (e) {\n        buddyUpGoogleStatus('Google sign-in could not be completed. Please try again.');\n    } finally {\n        if (!loginSucceeded) buddyUpSetLoginPendingState(false);\n        buddyUpLoginRequestInFlight = false;\n    }\n}\n\nif (document.getElementById('buddyUpGoogleLoginButton') && window.BUDDYUP) {\n    BUDDYUP.renderGoogleIdentityButton('buddyUpGoogleLoginButton', {\n        callback: buddyUpHandleGoogleLogin,\n        text: 'signin_with',\n    }).catch(() => buddyUpGoogleStatus('Google sign-in is temporarily unavailable.'));\n}\n\n\/***\n * Login Request\n *\/\nasync function buddyUpLogUserIn(){\n    if (buddyUpLoginRequestInFlight) return;\n    buddyUpLoginRequestInFlight = true;\n\n    var userLoginData = {};\n    userLoginData.email_address = document.getElementById('formEmail').value;\n    userLoginData.password = document.getElementById('formPWD').value;\n    if (buddyUpPendingGoogleCredential) userLoginData.google_credential = buddyUpPendingGoogleCredential;\n\n    buddyUpClearStaleAuthBeforeLogin();\n\n    let loginSucceeded = false;\n    try {\n        const receivedUserData = await BUDDYUP.apiRequest('login', userLoginData);\n        \n        if (await buddyUpFinishLoginIfAuthenticated(receivedUserData)){ \/\/ If user is received or auth already completed\n            loginSucceeded = true;\n            buddyUpPendingGoogleCredential = '';\n        } else { \/\/ If user info is incorrect, error handling\n            let errMessage = '';\n            const responseMessage = receivedUserData && (receivedUserData.message || receivedUserData.data) ? (receivedUserData.message || receivedUserData.data) : '';\n            \n            if (responseMessage && responseMessage !== ''){\n                if (responseMessage.includes('verify your email')){\n                    if (await buddyUpFinishLoginIfAuthenticated(receivedUserData)) {\n                        loginSucceeded = true;\n                        return;\n                    }\n\n                    const emailVerifyModal = `<div class=\"textHeading\"><\/div>\n                        <p>Please verify your email before logging in.<\/p>\n                        <p>If you do not see a verification email in your inbox, <strong>please check the spam folder.<\/strong> or click below to send a new one.<\/p>\n                        <button id=\"buddyUpResendEmail\" class=\"buddyUpButton1\">Resend Email<\/button>`;\n                    BUDDYUP.openModal(emailVerifyModal, 'Verify your email address', 'buddyUpVerifyEmailModal', { icon: 'fas fa-envelope-open-text' });\n\n                    document.getElementById('buddyUpResendEmail').addEventListener('click', () => {\n                        buddyUpLoginResendEmailSetup(userLoginData.email_address);\n                    });\n                } else {\n                    errMessage = responseMessage;\n                }\n            } else {\n                errMessage = 'The information you entered is incorrect. Please try again.';\n            }\n\n            if (errMessage !== ''){ \/\/ Show the err message if one is available\n                document.getElementById('formIncorrectInfo').innerHTML = errMessage;\n                document.getElementById('formIncorrectInfo').classList.remove('hidden');\n            }\n        }\n    } catch (e) {\n        document.getElementById('formIncorrectInfo').innerHTML = 'Login request timed out. Please try again.';\n        document.getElementById('formIncorrectInfo').classList.remove('hidden');\n    } finally {\n        if (!loginSucceeded) {\n            buddyUpSetLoginPendingState(false);\n        }\n        buddyUpLoginRequestInFlight = false;\n    }\n}\n\n\/***\n * Login Form Submit\n *\/\nvar loginSubmitButton = document.getElementById('buddyUpLoginTab');\nif (loginSubmitButton){\n    loginSubmitButton.addEventListener('submit', e => {\n        e.preventDefault();\n\n        if (buddyUpLoginRequestInFlight) return;\n\n        document.getElementById('formIncorrectInfo').classList.add('hidden');\n        buddyUpSetLoginPendingState(true);\n        buddyUpLogUserIn();\n    });\n}\n\n\n\/***\n * Password Reset Submit\n *\/\nasync function buddyUpForgotPassword(){\n    document.getElementById('buddyUpSendForgotPwd').setAttribute('disabled', 'disabled');\n    document.getElementById('formIncorrectInfo').classList.add('hidden');\n\n    var forgotPasswordData = {};\n    forgotPasswordData.email_address = document.getElementById('forgotPWDEmail').value;\n\n    const forgotPasswordRequest = await BUDDYUP.apiRequest('forgot-password', forgotPasswordData);\n    \n    document.getElementById('buddyUpSendForgotPwd').removeAttribute('disabled');\n\n    if (forgotPasswordRequest && forgotPasswordRequest.status === 'success'){\n        BUDDYUP.openModal('Please check your email for instructions on how to reset your password.', 'Password Reset Request', 'passwordResetModal');   \n    } else {\n        BUDDYUP.openModal('An error occurred trying to reset your password.<br\/>Please try again later.', 'An error occurred', 'passwordResetModal');   \n    }\n}\n\nvar passResetSubmit = document.getElementById('buddyUpPwdTab');\nif (passResetSubmit){\n    passResetSubmit.addEventListener('submit', e => {\n        e.preventDefault();\n        buddyUpForgotPassword();\n    });\n}\n\nvar showPasswordButton = document.getElementById('showPasswordButton');\nif (showPasswordButton){\n    showPasswordButton.addEventListener('click', e => {\n        e.preventDefault();\n        var icon = e.target.parentNode.querySelector('i');\n        var passwordInput = document.getElementById('formPWD');\n\n        if (passwordInput.getAttribute('type') === 'password'){\n            passwordInput.setAttribute('type', 'text');\n            icon.classList.remove('fa-eye');\n            icon.classList.add('fa-eye-slash');\n        } else {\n            passwordInput.setAttribute('type', 'password');\n            icon.classList.remove('fa-eye-slash');\n            icon.classList.add('fa-eye');\n        }\n    });\n}\n\n\n\/***\n * Email Verify\n *\/\nfunction buddyUpLoginResendEmailSetup(email){\n    const resendEmailVerifyEl = `<div id=\"buddyUpVerifyEmailWrapper\">Sending a new email verification...<\/div>`;\n\n    BUDDYUP.openModal(resendEmailVerifyEl, '', 'buddyUpVerifyEmailModal');\n    buddyUpLoginResendEmailVerify(email);\n}\n\n\nasync function buddyUpLoginResendEmailVerify(email){\n    const emailResendResponse = await BUDDYUP.apiRequest('resend-verification-email', {email: email});\n\n    if (emailResendResponse.status === 'success'){\n        const resendEmailVerifyEl = `<p>We have sent a verification link to your email.<br\/>Click on the link to complete the verification process.<\/p>\n            <p>If you do not see the email, <strong>please check the spam folder.<\/strong><\/p>\n            <button id=\"buddyUpCloseModal\" class=\"buddyUpButton1\" style=\"margin: 0;\">Okay<\/button>`;\n\n        BUDDYUP.openModal(resendEmailVerifyEl, 'Verify your email address', 'buddyUpVerifyEmailModal', { icon: 'fas fa-envelope-open-text' });\n        document.getElementById('buddyUpCloseModal').addEventListener('click', () => { BUDDYUP.closeModal(); });\n    } else {\n        const message = emailResendResponse.message && emailResendResponse.message !== '' && !emailResendResponse.message.includes('route') ? `<br>${emailResendResponse.message}` : '';\n        const resendEmailVerifyEl = `<div id=\"buddyUpVerifyEmailWrapper\">\n            <p>We were unable to send a new email verification. Please try again.${message}<\/p>\n            <button id=\"buddyUpResentEmailAgain\" class=\"buddyUpButton1\">Resend Email<\/button>\n        <\/div>`;\n        \n        BUDDYUP.openModal(resendEmailVerifyEl, \"We're having some trouble\", 'buddyUpVerifyEmailModal');\n        document.getElementById('buddyUpResentEmailAgain').addEventListener('click', () => { buddyUpLoginResendEmailSetup(email); });\n    }\n}\n\n\n\/***\n * Email Verify Check\n *\/\nif (buddyUpHasEmailVerificationParams){\n    const resendEmailVerifyEl = `<div id=\"buddyUpVerifyEmailWrapper\">${BUDDYUP.loading()}<\/div><div class=\"textHeading\">Please Wait<\/div><p>Verifying your email<\/div>`;\n\n    BUDDYUP.openModal(resendEmailVerifyEl, '', 'buddyUpVerifyEmailModalVerifying');\n    BUDDYUP.clearAllElements('#buddyUpCloseModalButton'); \/\/ Remove the close button\n\n    buddyUpSendEmailVerification(\n        buddyUpVerifyParams.get('user_id'),\n        buddyUpVerifyParams.get('verification_id'),\n        buddyUpVerifyParams.get('validation_token')\n    );\n\n    async function buddyUpSendEmailVerification(userID, verifyID, validationToken){\n        const emailVerifyRequest = {\n            user_id: userID,\n            verification_id: verifyID,\n            validation_token: validationToken,\n        };\n\n        let sendVerifyResponse = await BUDDYUP.apiRequest('verify-email', emailVerifyRequest);\n        \n        if (sendVerifyResponse.status === 'success'){\n            var sendVerifyModalContent = `<p>Your email is verified.<br\/>Please log in to continue your adventure!<\/p>`;\n            BUDDYUP.openModal(sendVerifyModalContent, 'Verification Complete', 'buddyUpVerifyEmailModalVerifying', { icon: 'fas fa-envelope-open-text' });\n            \n            localStorage.setItem('buddyup_new_user', true);\n            try {\n                if (window.history && typeof window.history.replaceState === 'function') {\n                    window.history.replaceState({}, document.title, window.location.pathname);\n                }\n            } catch (e) {}\n        } else {\n            var sendVerifyModalContent = `<p>We seem to have hit a snag trying to verify your email. Please click the link in the verify email again to try again.<\/p>`;\n            BUDDYUP.openModal(sendVerifyModalContent, 'Something went wrong', 'buddyUpVerifyEmailModal', { icon: 'fas fa-exclamation-triangle' });\n        }\n    }\n}\n\n<\/script><\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"templates\/full-width-no-header.php","meta":{"footnotes":""},"class_list":["post-231","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/staging.buddyupgo.com\/api\/wp\/v2\/pages\/231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/staging.buddyupgo.com\/api\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/staging.buddyupgo.com\/api\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/staging.buddyupgo.com\/api\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/staging.buddyupgo.com\/api\/wp\/v2\/comments?post=231"}],"version-history":[{"count":0,"href":"https:\/\/staging.buddyupgo.com\/api\/wp\/v2\/pages\/231\/revisions"}],"wp:attachment":[{"href":"https:\/\/staging.buddyupgo.com\/api\/wp\/v2\/media?parent=231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}