2
fredrf
8y

Guys, I have a question and I was wondering if you could help me here...

I was thinking, is there a way to have a user login, and behind the scenes it will take to its "website"?

I.e.: Lets say, I have something like wordpress but for each instance, should I deploy a subdomain or, can I create a single entry point and then route the user to its specific wordpress instance?

Can you advise? Suggestions?

Thank you in advance

Comments
  • 1
    It might be overkill but WordPress Multisite essentially gives you this kind of behaviour. Have you looked into that at all?
  • 1
    @samk I am developing this from scratch, wordpress was used as an example, to ilustrate ehat I am trying to achieve
  • 1
    I assume you want a single login page for your clients which redirects them after login to their website demo. Right?
  • 1
    @pixeltherapy something like that... Is there some technology with this purpose?
  • 1
    you could store the website the user should be directed to in the db along side the login info and just retrieve that after a successful login
  • 1
    Well its just matter of mapping the subdomain to a route. For example someuser.example.com would map to example.com/account/someuser. Its all behind the scenes so user wont see the actual route. We do this currently with our nodejs/express app. Login should just redirect to accounts subdomain after successfull login.
  • 1
    @cahva ok nice! I like that idea

    Something like the account as the slug, and something like a "db selector" after login...

    FYi: I'm using Laravel
  • 1
    @fredrf what @cahva said.

    As you're working in WP already, the simplest may be to write your own WP 'plugin' that does what you want, rather than hacking the WP login. I'm sure there's an open source user auth plugin/library that you could just add routes to as @cahva suggests.

    Keep us posted :)
  • 1
    @pixeltherapy thank you for the suggestion, but I used WP as an example...
    I'm building my own product
  • 1
    @fredrf honestly I would do something like @Cruiser said. @cahva had a pretty good method too.

    Personally, I'm a .net developer and I was thinking of doing exactly what @Cruiser said.

    Ie: when the user creates an account, generate a sub-domain and put that in the db. Then, once the user logs in, they will be redirected to their exclusive sub-domain.

    When the user erases/de-activates thier account, delete the sub-domain.

    It should be pretty straight forward. I think you may be over complicating it if your having problems. It's easy to over complicate things IMO.
  • 1
    @champion01 its fairly easy to overcomplicate things!

    I like both suggestions!

    The subdomain redirect has the least impact on development right now...

    I'll have to think this one through
  • 1
    Subdomains sound like the simpler option, but might become an issue in the future.
    Where I work, we have an unified dashboard for all our products and the very first approach was to use sub domains, but when a client asked to merge and share contents between accounts, we had to go for a complete redesign.
    So, we built an ACL to allow us to customise every single variable, with layouts based on templates, so we can customise every single aspect of each view.
    That may sound to over complicate a simple task, but we could have spared spending thousands of euros in a full redesign...
  • 0
    @fermac yeah, Laravel allows me to create some kind of ACL through the middleware...

    I was thinking about going that way.

    I have to consider features (enable/disable, for each product version) and URL formating (mantaining a RESTfull way)

    I am comming to the ACL route...(it also avoids the deployment of several subdomains and the backend work it will generate)
  • 1
    Are you talking about SSO functionality ?
  • 0
    @sshntt yes, SSO. But more, the design/architecture behind it
  • 2
    Since you are building this from scratch, may I suggest taking a look at JASIG's CAS server. We built something similar to what you want to build. It was for our company's internal apps. A unified portal with single sign on access to all the apps. For ex, we had app1.mycompany.com, app2.mycompany.com, etc. signing into or out of app1 or app2 would sign me into or out of all the other apps. And CAS has good client libraries in various languages and integration was a breeze for us. Most of our apps were built on either the jvm or on node and our developers seemed to have enjoyed the experience.
  • 2
    We used our own implementation of JWT for the effect, if it helps.
    There's plenty of libraries to integrate it to all major languages.
  • 0
    #newStackOverflow
Add Comment