How to access to registration via login Widget?

Hi!

I’ve implemented the Sign In widget in my app using this url:

https://${myOktaDomain}/oauth2/default/v1/authorize

It works fine, but I actually want to enter directly to the registration form that is also available in this widget. The design I planned is a screen with two buttons (login and registration). The login button leads the user to the Sign In screen and I want the registration button to work as the login button but with the Sign Up case. Since the widget has it done, but with an anchor at the bottom of the login form I thought it would be also possible to access directly to the registration form when clicking the button on the app.

This is the step I’m looking to avoid:

Any suggestions?

Thanks in advance!

There is no built in way to achieve this. See related threads about this question for reference/options:

and an older GH thread about this request: Initialize Widget directly in registration view · Issue #587 · okta/okta-signin-widget · GitHub


One of the more common solutions I’ve heard of is to emulate the user clicking this button so the registration view is shown instead. See some example code for what this looks like below (note that the class name may vary depending on the widget version being used):

// Render the Okta Sign-In Widget
var oktaSignIn = new OktaSignIn(config);

oktaSignIn.on('afterRender', function (data) {
  // This is the code that makes it look as if the Okta Sign-In Widget has been loaded to the "Registration" view
  const view = data.controller;
  if(view == 'primary-auth') {
    if(registrationNotClicked) {
      registrationNotClicked = false;
      document.getElementsByClassName("registration-link")[0].click();
    }

Thanks for answering. After many days looking for a solution I think this is the only way to get it. I’ll be looking for this feature in the next updates of the Widget.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.