XF 2.2 Enable registration unchecked doesn't completely prevent registrations with associated account

El Porcharo

Well-known member
Facebook use to periodically verify their developers applications compliance, so one of their staff members contacted me complaining that I had to provide a test user account, so they could verify my application work flow and compliance as it seemed that it wasn't being used properly by my app.

At the beginning, I replied in a quite rude manner, as I got bored with this company continuously bothering their users (plus their site sucks! 😵‍💫).

On my board the "Enable registration" option is unchecked, because I setup a custom registration workflow as I need to verify that people who apply are professionals of my niche.

1639234262260.webp

After a couple of replies with this FB staff members, they finally showed me a screenshot to show me the error they were going to face.

This is when I realized that if you try to log in by one of the available external services without having your account already associated (I set up Facebook, Google, LinkedIn and - thanks to an add-on - Telegram), XenForo will redirect you to the "Create new account" tab instead of hiding it and showing the "Associate existing account", even if "Enable registration" is unchecked.

That's why they get the following error, as they try to go ahead by clicking the Register button:

1639234280609.webp



I don't know if this is meant to be like this or it's a sort of bug for the "Connected account" feature, but I'm sure the "Create new account" tab shouldn't be there if user registration is disabled in the ACP.


I will see if I can work this around with a template modification, while waiting for someone to provide a real solution to this issue.


Thanks for your attention! 😅
 
I will see if I can work this around with a template modification

Alright, here's my temporary (I hope) workaround:

Close your board, then enable developer mode and go to ACP>Appearance>Template modifications and click the Add template modification button.

In the Template field add register_connected_account, then choose a Modification key of your liking (hide_register_with_if_disabled in my case), then write down something that will remind you what this template modification is for, in the Description field

1639248098494.png


Scroll down without touching any option until you reach the Find text field

1639248377634.png

Add the following code to it:
PHP:
<xf:title>{{ phrase('register_using_x', {'provider': $provider.title}) }}</xf:title>

<xf:set var="$user" value="{{ $user ?: $xf.visitor }}" />
<xf:js src="xf/login_signup.js" min="1" />

<xf:head option="robots"><meta name="robots" content="noindex" /></xf:head>

<xf:form action="{{ link('register/connected-accounts/register', $provider) }}" ajax="true" class="block">
    <div class="block-container">
        <h2 class="block-tabHeader tabs" data-xf-init="tabs" role="tablist">
            <a class="tabs-tab is-active" role="tab" tabindex="0" aria-controls="{{ unique_id('regCreate') }}">
                {{ phrase('create_new_account') }}
            </a>
            <a class="tabs-tab" role="tab" tabindex="0" aria-controls="{{ unique_id('regAssoc') }}">
                {{ phrase('associate_existing_account') }}
            </a>
        </h2>

        <ul class="tabPanes">
            <li class="is-active"
                data-xf-init="reg-form"
                data-timer="{$xf.options.registrationTimer}"
                role="tabpanel"
                id="{{ unique_id('regCreate') }}">

                <div class="block-body">
                    <xf:macro template="register_macros" name="username_row" />

                    <xf:if is="$providerData.email">
                        <xf:formrow label="{{ phrase('email') }}">{$providerData.email}</xf:formrow>
                    <xf:else />
                        <xf:macro template="register_macros" name="email_row" />
                    </xf:if>

                    <xf:if is="!$providerData.dob">
                        <xf:macro template="register_macros" name="dob_row" />
                    </xf:if>

                    <xf:if is="!$providerData.location">
                        <xf:macro template="register_macros" name="location_row" />
                    </xf:if>

                    <xf:macro template="register_macros" name="custom_fields" />

                    <xf:macro template="register_macros" name="email_choice_row" />

                    <xf:macro template="register_macros" name="tos_row" />
                </div>
                <xf:macro template="register_macros" name="submit_row" />

            </li>
            <li role="tabpanel" id="{{ unique_id('regAssoc') }}">
                <div class="block-body block-row">
                    {{ phrase('to_associate_existing_account_first_log_in_start_via_connected_accounts', {
                        'link': link('account/connected-accounts')
                    }) }}
                </div>
            </li>
        </ul>

1639248329954.png


Then paste this in the next Replace field:

PHP:
<xf:title>{{ phrase('associate_with_x', {'provider': $provider.title}) }}</xf:title>

<xf:set var="$user" value="{{ $user ?: $xf.visitor }}" />
<xf:js src="xf/login_signup.js" min="1" />

<xf:head option="robots"><meta name="robots" content="noindex" /></xf:head>

<xf:form action="{{ link('register/connected-accounts/register', $provider) }}" ajax="true" class="block">
    <div class="block-container">
        <h2 class="block-tabHeader tabs" data-xf-init="tabs" role="tablist">
<xf:if is="$xf.options.registrationSetup.enabled">
            <a class="tabs-tab is-active" role="tab" tabindex="0" aria-controls="{{ unique_id('regCreate') }}">
                {{ phrase('create_new_account') }}
            </a>
            <a class="tabs-tab" role="tab" tabindex="0" aria-controls="{{ unique_id('regAssoc') }}">
                {{ phrase('associate_existing_account') }}
            </a>
</xf:if>
        </h2>

<xf:if is="$xf.options.registrationSetup.enabled">
        <ul class="tabPanes">
            <li class="is-active"
                data-xf-init="reg-form"
                data-timer="{$xf.options.registrationTimer}"
                role="tabpanel"
                id="{{ unique_id('regCreate') }}">

                <div class="block-body">
                    <xf:macro template="register_macros" name="username_row" />

                    <xf:if is="$providerData.email">
                        <xf:formrow label="{{ phrase('email') }}">{$providerData.email}</xf:formrow>
                    <xf:else />
                        <xf:macro template="register_macros" name="email_row" />
                    </xf:if>

                    <xf:if is="!$providerData.dob">
                        <xf:macro template="register_macros" name="dob_row" />
                    </xf:if>

                    <xf:if is="!$providerData.location">
                        <xf:macro template="register_macros" name="location_row" />
                    </xf:if>

                    <xf:macro template="register_macros" name="custom_fields" />

                    <xf:macro template="register_macros" name="email_choice_row" />

                    <xf:macro template="register_macros" name="tos_row" />
                </div>
                <xf:macro template="register_macros" name="submit_row" />

            </li>
            <li role="tabpanel" id="{{ unique_id('regAssoc') }}">
                <div class="block-body block-row">
                    {{ phrase('to_associate_existing_account_first_log_in_start_via_connected_accounts', {
                        'link': link('account/connected-accounts')
                    }) }}
                </div>
            </li>
        </ul>
<xf:else />
            <span id="{{ unique_id('regAssoc') }}">
                <div class="block-body block-row">
                    {{ phrase('to_associate_existing_account_first_log_in_start_via_connected_accounts', {
                        'link': link('account/connected-accounts')
                    }) }}
                </div>
            </span>
</xf:if>

Click the Save button, so now you can disable development mode (either by deleting the line of code or adding a double slash // at the beginning) and open your board again.

Done.
 
Top Bottom