How do you use loginWithPassword with username instead of email


#1

Hi there, I have this wired problem with login using username instead of email address

Basically, I create a user with fixed password using

Accounts.createUser({
            email: username,
            password: 'dfsgsefhse5rtawrgagfgad'
        });

Then tried to login with

Meteor.loginWithPassword({username: username}, password, function(error) {
      console.log(error)
    });

I get a 403 error, User not found, however if I create user using email it seems to work
here is the user in DB

{
	"_id" : "7EZMmoXwskwcRv4us",
	"createdAt" : ISODate("2017-09-13T01:29:40.522Z"),
	"services" : {
		"password" : {
			"bcrypt" : "$2a$10$cKflMjRTmunpvSJoVjW6e.xfWCP59yqJyAnhLJgPjmMeUalyt/jV."
		},
		"resume" : {
			"loginTokens" : [ ]
		}
	},
	"emails" : [
		{
			"address" : "test",
			"verified" : false
		}
	]
}

Thanks in advance


#2

Nevermind, i got it

Meteor.loginWithPassword({email: username}, password, function(error) {
      console.log(error)
    });

changed to {email: username}, and it all works