Login to get @userId from server

I was trying to write test code using Mocha for MeteorJS. I had a method that uses @userId

. This only happens when the user is logged in. I am doing server side testing and would like to add @userId

explicitly that I failed as it can only be accessed within methods. and I tried to login using Meteor.loginWithPassword

reference http://docs.meteor.com/#/full/meteor_loginwithpassword . But it throws an error.

Object # has no method 'loginWithPassword'

While testing, I found out that the method is only available from the client side.

So my question is, how do I log in from server side code? or is there a way to initialize @userId explicitly external method inside server side code?

Thank you, go ahead.

+3


source to share


1 answer


There is currently no native way to authenticate a user completely server side with Meteor.



I suggest running Meteor.loginWithPassword()

on the client and linking it to something like Meteor.validateLoginAttempt()

that that will allow you to, among other things, access the user object (and thus the userId).

+1


source







All Articles