It works with Meteor version >= 0.8.2
Smart package for Meteor framework.
Provides function for Meteor framework to log in using "username" stored in specified profile fields.
Could be used as a replacement for loginWithPassword()
function.
accounts-profile-fields
needs to be installed with accounts-base
package.
So, at first you need to install it by:
meteor add accounts-base
meteor add accounts-profile-fields
In example below login name 'ABC123456' is checked against fields: ['profile.register_plate', 'profile.phone_number', 'username', 'emails.email'] from 'users' collection. At first are checked fields from 'profile'.
Define in file settings.json
fields used to find user, for example:
{
"login_with_profile_fields": ["register_plate","phone"]
}
var login = 'ABC123456';
var password = '123456';
Meteor.loginWithProfileField(login, password, function(err) {
if(Meteor.loggingIn()) {
console.log("logging in...");
} else {
if(err) {
console.log("log.err= " + err);
} else {
console.log("loggged in!");
}
}
});
meteor --settings=settings.json