How to implement cross-domain login across multiple subdomains with Memberstack's single custom domain limit?

Post author
ilyas el megarbi

I have the main root domain which is glori.io, and i have subdomains for my web app i use my.glori.io for the sales pages I use get.glori.io for the root domain im hosting on it something else so i'm not using it, i want to have the ability of cross domain login, so here is how it goes in get.glori.io they will signup in this domain the only thing is for the user to signup, but in my.glori.io they will be able to login and browse all the hosted content, and btw the live domain on memberstack is my-glori-io, so my question how to do that because in custom domain in memberstack they only allows to connect one subdomain and one root domain so how can I do that.

Comments

7 comments

  • Comment author
    A J

    Hey ilyas el megarbi,

    Based on the tutorial the sub-domain needed to enter there does not refer to a list of sub-domains you want to setup the Cross domain login for. Instead, we just need to say what sub-domain do we want to show to the users when they try to login via SSO, by default its auth.memberstack.com, so when we setup a custom domain - in your case glori.io, you can setup the sub-domain to be something like login.glori.io in the member-facing subdomain setting.

    And the place where you have to list the root domain and all the sub-domains to enable Cross domain login feature is in the Application domain section (the one above the DNS settings that you are setting up currently) in Memberstack dashboard and then follow along with the guide to finish the setup. Hope this helps.

    0
  • Comment author
    ilyas el megarbi

    Hey, I’m running into an issue with my cross-domain login setup.

    • Setup: get.glori.io is where users sign up, and after signing up they’re redirected to my.glori.io. I’ve configured the redirect links, added the cookie script, and authenticated the root domain.
    • Issue: The signup and redirect flow works correctly, and logging out redirects back to the signup page as expected. However, if I go back to the previous page or directly enter a Gated URL, the page still loads instead of showing an “access denied” or login requirement. Essentially, the session doesn’t seem to clear properly after logout.

    Here is the link to test it out:
    Sign up page: https://get.glori.io/sign-up-dummy

    Here is the Gated URLs,
    If I opened the gated URL in a different device that never been logined in to before, instead of redirecting me to the access page, it shows the Gated Page even when i've never loged an account in that device
     
    0
  • Comment author
    A J

    Hey ilyas el megarbi,

    Can you ensure that the starting with URLs are mentioned as slugs instead of the entire URL?

    i.e. if you want to gate access to https://my.glori.io/dashboard, can you set the rule as starting with rule with just dashboard/

    Do this for one URL and save it to test it out, ideally it should work. Same goes for the Access Denied URL, you could specify just access-denied

    Let me know if you still face any issue.

    0
  • Comment author
    ilyas el megarbi

    It worked thanks a lot

    And also in my pawordless sign in page i set up this attribute to show the email where the 6-digit code is been sent but it doesn't work
    0
  • Comment author
    A J

    Hey ilyas el megarbi,

    Do you also have this script embedded on the page custom code section before the closing body tag?

    <script>
      // Get the input and span elements based on the custom attributes
      const input = document.querySelector('[data-ms-member="email"]');
      const span = document.querySelector('[data-msx-text="email"]');
    
      // Add an event listener to the input element
      input.addEventListener('input', function() {
        // Update the text content of the span with the value of the input
        span.textContent = input.value;
      });
    </script>
    

    If yes, and if it still does not work, can you share a read-only link of the site to troubleshoot this?

    0
  • Comment author
    ilyas el megarbi

    i didn'T install the script i just did thanks man

    0
  • Comment author
    A J

    Welcome 😇

    0

Please sign in to leave a comment.