Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor - single-page app on client, but only after login - how do I accomplish this?

Tags:

meteor

I would like to build the following functionality with Meteor:

  1. User goes to the website and is greeted with a login/signup form and nothing else. I don't want the client to have any other information from the server at all. Just the simplest possible login/signup form.

  2. If the user successfully logs in or signs up, only then do I want the full app, with all he templates, etc., downloaded to the client.

Is it possible to accomplish this with Meteor?

like image 504
tadasajon Avatar asked Feb 15 '23 23:02

tadasajon


1 Answers

I think you have a few of options:

  • [Hard] Single meteor app

    Hook into the node request processing pipeline and do the interception there before the rest of Meteor get's involved. Probably easiest to do this in server.js. Can't use Meteor constructs - have to use regular node and NPM packages but you can write the login tokens to the same MongoDB backend.

  • [Easier] Two Meteor apps

    Write a separate Meteor app that only does the login and writes the tokens to the same DB, then redirects to different URL. Use a reverse proxy to control which app handles which URL.

  • [Easiest] Wait for server-side rendering support in Meteor core

    Guessing it will come sometime early Q2 2014

Haven't tested these but I think as long as the login tokens end up in the user's account on the DB and the root domain is the same, this will work.

== Update ==

Regarding the login app, this atmosphere package provides pre-made login pages (requires IronRouter):

  • accounts-entry

== Update 2 ==

The 2 Meteor app solution is applicable for a more general, "I want to split my app across different 'areas' ". In the specific case asked about by the OP of a simple login form, we can just use a static HTML page for the initial landing page and not even worry about the 2nd Meteor app. The reverse proxy would route traffic between these 2 endpoints:

  • a statically served landing page (Nginx, apache, etc)
  • the real Meteor app

Using something like Route53 and S3 buckets, I think it would even be possible to serve the initial landing page directly from CDN although I haven't worked through it all.

like image 111
alanning Avatar answered May 23 '23 00:05

alanning