FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    Registration fields pre-fill from URL

    Scheduled Pinned Locked Moved Solved
    Q&A
    2
    5
    722
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      ctorres
      last edited by

      Hi,

      I'm trying to implement an invitation workflow for new users which is triggered from inside my application.

      The result is that the invitee receives an email with a link to simply login if the user was previously determined to be in my FusionAuth instance, but if the user does not exist, then the link is to the registration form. Here is an example link:

      https://auth.whatevermyappis.com/oauth2/register?tenantId=8537366e-84dc-4711-a465-eadd8cea2f1c&client_id=757504bb-6c14-4913-bb50-608ad5ff46e2&pendingIdPLinkId=&redirect_uri=https%3A%2F%2Fapp.whatevermyappis.com&response_mode=form_post&response_type=code&scope=openid%20profile
      

      I would like to be able to add some additional parameters in the url that would pre-populate some fields on the registration UI, for example, the Email, First Name and Last Name are known to my when the URL is crafted and the invitation email is sent.

      It would be even better if those fields would be even better if those fields will be disabled from editing (at least the email) so whichever email was sent by the person doing the invitation will be the same one the end-user will use for registration.

      Finally, i would be amazing if a parameter could drive that email is marked as verified since the link was clicked because the email was succesfully received by the end-user.

      Please let me know if this is possible, or any workaround already exist, if not, how do i put it as a feature request.

      Thanks

      1 Reply Last reply Reply Quote 0
      • C
        ctorres
        last edited by

        Hahaha, i was able to figure out half of it by adding these at the end:

        &user.firstName=Anakin&user.lastName=Skywalker&user.email=anakin@tattoine.com
        

        Any ideas for the email verification and potential blocking of the fields?

        1 Reply Last reply Reply Quote 0
        • C
          ctorres
          last edited by

          I was able to block the fields on the registration form by adding this javascript to the OAuth Register theme:

          <script type="text/javascript">
          	window.onload = function () {
          		const queryString = window.location.search;
          		const urlParams = new URLSearchParams(queryString);
          		if (urlParams.has('user.email'))
          			{
          		        document.getElementById("email").disabled = true;
          				document.getElementById("firstName").disabled = true;
          				document.getElementById("lastName").disabled = true;
          			}
          	};
          </script>
          

          So if the registration form is used directly it workes as before, but if i'm passing the parameters on the URL from the invitation email, then those fields are pre-populated and blocked.

          I also disabled the email verification altogether, so that is not a issue anymore.

          1 Reply Last reply Reply Quote 0
          • C
            ctorres
            last edited by

            Sorry, after further testing i noticed that if the registration fields are disabled, then the registration process is ignoring them. I had to emulate the disable with "readonly" and some style:

            <script type="text/javascript">
            window.onload = function () {
            	const queryString = window.location.search;
            	const urlParams = new URLSearchParams(queryString);
            	if (urlParams.has('user.email'))
            	{
            		document.getElementById("email").readOnly = true;
            		document.getElementById("email").style.backgroundColor = "#1e73be";
            		document.getElementById("firstName").readOnly = true;
            		document.getElementById("firstName").style.backgroundColor = "#1e73be";
            		document.getElementById("lastName").readOnly = true;
            		document.getElementById("lastName").style.backgroundColor = "#1e73be";
            	}
            };
            </script>
            
            danD 1 Reply Last reply Reply Quote 0
            • C ctorres has marked this topic as solved on
            • danD
              dan @ctorres
              last edited by

              @ctorres Awesome, thanks for sharing your process!

              --
              FusionAuth - Auth for devs, built by devs.
              https://fusionauth.io

              1 Reply Last reply Reply Quote 0
              • First post
                Last post