I’m trying to create a login handler that will select a user and login.
Server
Accounts.registerLoginHandler(function insecureUserLogin(options) {
console.log(options);
const { email } = options;
const user = email ? Accounts.findUserByEmail(email) : Meteor.users.findOne();
if (!user) { console.error('No users to login as'); return {}; }
return {
userId: user._id,
};
});
Client
Meteor.insecureUserLogin = function insecureUserLogin(options, callback) {
Accounts.callLoginMethod({
methodArguments: [options],
userCallback: callback,
});
};
Trying to login with this leaves the client stuck in ‘logging in’.