سؤال

Is it possible to log a user in from the server side? I am trying to create a url where an external service/app can login to the meteor server.

I tried doing the following:

Meteor.call('login', {
                password: data.password,
                user: {
                    email: data.email
                }
            }, function (error, result) {
                console.log(error);
                console.log(result);
            });

When called with invalid data such as an email that does not exist or an incorrect password I receive proper error messages like Incorrect Password. But has soon as it is a valid email and password that does exist on the database I receive the following error [TypeError: Cannot read property 'id' of null] So what I would like to know is 1) Can I log a user in on the server with this meteor call and 2) Am I doing it properly or is there another way?

هل كانت مفيدة؟

المحلول

In a word, no. The external service would either need to be running meteor client code or it would need to manually make a DDP connection. I suspect you are looking to make a generic-looking HTTP endpoint that any server can connect to. If that's the case, your best bet at the moment is to use something like an API key.

  1. Distribute a unique key to each user/customer/service.
  2. Require the key in each HTTP request (server-side route).
  3. Hope that the keys are not misused/exposed, and program with that possibility in mind.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top