How to send custom data with Meteor.loginWithPassword

Hi, I would like to ask, how to add a custom data to Meteor.loginWithPassword method to sent it from client to server side.

  • I want to add geolocation data (coordinates) and process/save them on server side.
  • Next I want to add data from Google captcha.

Thanks a lot for each help.

Use a local state on the client and send them through to the server as an effect of having a valid Meteor.userId() (and having a valid Meteor.userId at startup). A user may log in from a city in US and have a valid token for 60 days while, in this time, she may access the app from multiple countries/locations). You can also save this in localStore and compare at every startup and resave to Meteor if location changed.

1 Like

Thanks a lot @paulishca for your answer. Yes, after user will be logged in, I can send the location data into meteor server, but, I’m thinking about possibility to use location data during logging and registration process in onCreateUser and in validateLoginAttempt on server side.

…or I’m thinking bad way?

…the same I need also with the Google captcha (send data from client side to server and validate captach user on server side).

Thanks a lot again.

You can create a custom login method.

1 Like

You can add some behavior to the login functionality.

See: AccountsCommon-onLogin and AccountsServer-validateLoginAttempt