Social providers in Register web page



  • I'd like to link directly the signup page from app, instead of linking the login page then from there go the Register page (form).

    Is it possible to have my configured social providers in the signup page ?
    I've try playing around with the templates in Themes > Register by copy-pasting code from Themes > Autotorize that seem relevant but I keep getting errors.

    I've copied the helpers.head from /authorize who crashes calling @helpers.alternativeLoginsScript

    [#ftl/]
    [#-- @ftlvariable name="application" type="io.fusionauth.domain.Application" --]
    [#-- @ftlvariable name="collectBirthDate" type="boolean" --]
    [#-- @ftlvariable name="hideBirthDate" type="boolean" --]
    [#-- @ftlvariable name="passwordValidationRules" type="io.fusionauth.domain.PasswordValidationRules" --]
    [#-- @ftlvariable name="parentEmailRequired" type="boolean" --]
    
    [#-- @ftlvariable name="client_id" type="java.lang.String" --]
    [#-- @ftlvariable name="identityProviders" type="java.util.Map<java.lang.String, java.util.List<io.fusionauth.domain.provider.BaseIdentityProvider<?>>>" --]
    
    [#import "../_helpers.ftl" as helpers/]
    
    [@helpers.html]
    [#-- Copied the header from /authorize --]
      [@helpers.head]
        <script src="/js/jstz-min-1.0.6.js"></script>
        <script src="/js/oauth2/Authorize.js?version=${version}"></script>
        [@helpers.alternativeLoginsScript clientId=client_id identityProviders=identityProviders/]
        <script>
          Prime.Document.onReady(function() {
            [#-- This object handles guessing the timezone and filling in the device id of the user --]
            new FusionAuth.OAuth2.Authorize();
            [#--
             To use an in-progress indicator when waiting for an external identity provider such as Google.
               - The panel class will make the default FusionAuth login panel show "in progress". Modify
                 this selector if your HTML has been modified, or use your own in progress indicator.
            --]
            var panel = Prime.Document.queryFirst('.panel');
            if (panel !== null) {
              FusionAuth = FusionAuth || {};
              FusionAuth.IdentityProvider = FusionAuth.IdentityProvider || {};
              FusionAuth.IdentityProvider.InProgress = new Prime.Widgets.InProgress(panel);
            }
          });
        </script>
      [/@helpers.head]
    

    and get the following runtime error (printed on the browser):

    FreeMarker template error (DEBUG mode; use RETHROW in production!):
    When calling macro "alternativeLoginsScript", required parameter "identityProviders" (parameter #2) was specified, but had null/missing value.
    
    ----
    Tip: If the parameter value expression on the caller side is known to be legally null/missing, you may want to specify a default value for it with the "!" operator, like paramValue!defaultValue.
    ----
    
    ----
    FTL stack trace ("~" means nesting-related):
    	- Failed at: #macro alternativeLoginsScript client...  [in template "##7f0a976d-2ba4-4d3e-8e93-095477c267fe##/WEB-INF/templates/_helpers.ftl" in macro "alternativeLoginsScript" at line 156, column 1]
    	- Reached through: @helpers.alternativeLoginsScript clie...  [in template "##7f0a976d-2ba4-4d3e-8e93-095477c267fe##/WEB-INF/templates/oauth2/register.ftl" at line 18, column 5]
    	~ Reached through: #nested  [in template "##7f0a976d-2ba4-4d3e-8e93-095477c267fe##/WEB-INF/templates/_helpers.ftl" in macro "head" at line 110, column 3]
    	~ Reached through: @helpers.head  [in template "##7f0a976d-2ba4-4d3e-8e93-095477c267fe##/WEB-INF/templates/oauth2/register.ftl" at line 15, column 3]
    	~ Reached through: #nested  [in template "##7f0a976d-2ba4-4d3e-8e93-095477c267fe##/WEB-INF/templates/_helpers.ftl" in macro "html" at line 26, column 3]
    	~ Reached through: @helpers.html  [in template "##7f0a976d-2ba4-4d3e-8e93-095477c267fe##/WEB-INF/templates/oauth2/register.ftl" at line 13, column 1]
    ----
    
    Java stack trace (for programmers):
    ----
    freemarker.core._MiscTemplateException: [... Exception message was already printed; see it above ...]
    	at freemarker.core.Macro$Context.sanityCheck(Macro.java:221)
    	at freemarker.core.Environment.invoke(Environment.java:774)
    	at freemarker.core.UnifiedCall.accept(UnifiedCall.java:83)
    	at freemarker.core.Environment.visit(Environment.java:366)
    	at freemarker.core.Environment.invokeNestedContent(Environment.java:618)
    	at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
    	at freemarker.core.Environment.visit(Environment.java:366)
    	at freemarker.core.Environment.invoke(Environment.java:775)
    	at freemarker.core.UnifiedCall.accept(UnifiedCall.java:83)
    	at freemarker.core.Environment.visit(Environment.java:366)
    	at freemarker.core.Environment.invokeNestedContent(Environment.java:618)
    	at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
    	at freemarker.core.Environment.visit(Environment.java:366)
    	at freemarker.core.Environment.invoke(Environment.java:775)
    ....
    

    What did I miss ?

    Thanks !

    (I'm running fusionauth 1.16.1.)



  • Hiya,

    The issue is that the identityProviders map needs to be populated for that login script to work, and the class behind this page doesn't provide that map. So for now I don't see a way to do this.

    There is an open github issue to allow identity providers to be displayed on the registration page. I'd suggest adding your use case to that issue: https://github.com/FusionAuth/fusionauth-issues/issues/554 and I'm happy to rename it to something more general. Alternatively you can file a new issue if you feel the use case is distinct enough.