Вопрос

It seems like one would need to use iron-router (or similar) to create an endpoint route. This certainly shouldn't be done client side; but I'm unsure how to approach implementing this server side because you can't check if a user is logged in (Meteor reports that Meteor.userId can only be invoked in method calls):

this.route('sso', {
  where: 'server',
  path: '/sso',
  onBeforeAction: function() {
    if (Meteor.user()) {
      this.redirect('endpoint url');
    }
  }
});

What would be an optimal approach for implementing a single sign on endpoint in Meteor?

Это было полезно?

Решение

In Meteor, this is actually handled on the client after the app loads, so that "the query string is not sent over the wire with the HTTP request".

Check out the Meteor code for handling password resets and email verification for how it's done:

https://github.com/meteor/meteor/blob/devel/packages/accounts-base/url_client.js

This is part of the wider accounts-base package, Meteor's user accounts system:

https://github.com/meteor/meteor/tree/devel/packages/accounts-base

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top