Problem
On account creation I want the users to access their profile as username.domain-name.com
I also have website features as :
username.domain-name.com/feature1
username.domain-name.com/feature2
username.domain-name.com/feature3
Above links might have content which can be accessed by other users if above user has allowed him access.
Example:
user1.domain-name.com/feature1
, here user1 has given access to user2
Hence, user2 has logged in and on visiting user1.domain-name.com/feature1
he should be able to see the content.
My research so far:
I tried following links:
https://kadira.io/blog/meteor/sharing-meteor-login-state-between-sub-domains
https://github.com/jfrolich/meteor-subdomain-persistent-login
After reading a lot, I found that meteor has localStorage as the way to store user login details. So, I have to somehow manage to pass the details to sub-domains. I also tried using proxy_pass in nginx config to do the following:
Request:
username.domain-name.com/feature1
should be proxied to ( not re-direct URL would be same) domain-name.com/username/feature1
If someone would put some light here on the approach I should use would really help me.
I know this design might not be good for search engines.
Update
I am now successfully using following design: if user1 is logged-in at domain-name.com and wants to visit his own profile page like user1.domain-name.com/profile.
Step1: user1 visits user1.domain-name.com/profile it redirects to domain-name.com where user1 had session in localstorage then reading HTTP header referrer I get user1.domain-name.com/profile and prepare new url: user1.domain-name.com/profile?token=userToken (I might create another temp token in db with one click exp.)
Step2: redirect to new url user1.domain-name.com/profile?token=userToken, using get parameter i create new session in localstorage and redirect user1 back to user1.domain-name.com/profile.
This is very unconventional solution, I am still re-searching.