Accounts.registerLoginHandler not firing [Meteor 1.3]


#1

The login handler never fires and I cant seem to figure why. I think it may no longer be supported?

/server/Auth.jsx

Accounts.registerLoginHandler(function(request) {

	if(!(request.platform && request.fqdn)) {
		return undefined;
	}

	var user = Accounts.findUserByEmail(request.email);

	if (!user)
		throw new Meteor.Error(403, "User not found");

	if (!user.services || !user.services.password ||
		!(user.services.password.bcrypt || user.services.password.srp))
		throw new Meteor.Error(403, "User has no password set");

	//sending token along with the userId
	return Accounts._checkPassword(
		user,
		options.password
	);
});

/client/lib/Auth.jsx

Meteor.signinWithPassword = function(email, password) {
	const args = {
		platform: Meteor.isCordova ? 'mobile' : 'browser',
		email: email,
		password: Accounts._hashPassword(password),
		fqdn: Actions.getTenantID() || Meteor.settings.public.fqdn
	};

	console.log(args);

	return new Promise((resolve, reject) => {
		Accounts.callLoginMethod({
			methodArguments: [args],
			userCallback(error){
				if(error){
					reject(error)
				}else{
					resolve()
				}
			}
		})
	})
};

When I do try this the result is:
{error: "UserNotFound", reason: "Account not found", details: undefined, message: "Account not found [UserNotFound]", errorType: "Meteor.Error"}


#2

How do you know the login handler is not firing?
Is the accounts-password package in your project?


#3

I placed a console.log in the loginHandler function above if(!(request.platform && request.fqdn)) { and it did log anything :frowning2:


#4

Bump. Still can’t figure it out…


#5

Figured it out. My args object in /client/lib/Auth.jsx need to be in the format:

const args = {
	platform: Meteor.isCordova ? 'mobile' : 'browser',
	user: {
             email: email,
	     password: Accounts._hashPassword(password)
        },
	fqdn: Actions.getTenantID() || Meteor.settings.public.fqdn
};