Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Meteor.loginWithPhoneAndPassword fails #5

Open
byrne-yan opened this issue Aug 27, 2015 · 11 comments
Open

Meteor.loginWithPhoneAndPassword fails #5

byrne-yan opened this issue Aug 27, 2015 · 11 comments

Comments

@byrne-yan
Copy link

I20150827-20:05:10.205(8)? Exception while invoking method 'login' Error: Match error: Unknown key in field phone in field user.phone
I20150827-20:05:10.205(8)? at packages/check/match.js:299:1
I20150827-20:05:10.205(8)? at Function..each..forEach (packages/underscore/underscore.js:113:1)
I20150827-20:05:10.205(8)? at checkSubtree (packages/check/match.js:290:1)
I20150827-20:05:10.206(8)? at check (packages/check/match.js:32:1)
I20150827-20:05:10.206(8)? at [object Object].condition (packages/accounts-password/password_server.js:111:1)
I20150827-20:05:10.206(8)? at checkSubtree (packages/check/match.js:220:1)
I20150827-20:05:10.206(8)? at packages/check/match.js:293:1
I20150827-20:05:10.206(8)? at Function..each..forEach (packages/underscore/underscore.js:113:1)
I20150827-20:05:10.206(8)? at checkSubtree (packages/check/match.js:290:1)
I20150827-20:05:10.207(8)? at check (packages/check/match.js:32:1)
I20150827-20:05:10.207(8)? at [object Object].Accounts.registerLoginHandler.check.user (packages/accounts-password/password_server.js:144:1)
I20150827-20:05:10.207(8)? at packages/accounts-base/accounts_server.js:358:1
I20150827-20:05:10.207(8)? at tryLoginMethod (packages/accounts-base/accounts_server.js:161:1)
I20150827-20:05:10.207(8)? at runLoginHandlers (packages/accounts-base/accounts_server.js:355:1)
I20150827-20:05:10.207(8)? at [object Object].Meteor.methods.login (packages/accounts-base/accounts_server.js:409:1)
I20150827-20:05:10.208(8)? at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1)

In file password_server.js of package accounts-password:
only one of id,username and email allowed!

@byrne-yan
Copy link
Author

This issue was caused by LoginHandler registered by Accounts-password package.

@byrne-yan
Copy link
Author

Another property name like 'phonepassword' instead of 'password' need be used to work with accoutns-password package in a same project.

@mayinhosa
Copy link

+1
having the same issue.

@byrne-yan how exactly did you work around this?

@dennishu001
Copy link

It seems to have something to do with the order the login service is registered. I added account-password as a root package, and downloaded and added accounts-phone as a local package. It seem to work for now.

@arvi
Copy link

arvi commented Nov 27, 2015

I'm having the same issue. I followed https://meteorhacks.com/extending-meteor-accounts tutorial for custom authentication then did meteor add accounts-password package since I want to use Accounts.createUser instead of the normal mongodb insert.

I20151127-16:01:52.001(8)? Exception while invoking method 'login' Error: Match error: Unknown key in field admin
I20151127-16:01:52.002(8)?     at check (packages/check/match.js:33:1)
I20151127-16:01:52.002(8)?     at [object Object].Accounts.registerLoginHandler.check.user (password_server.js:248:3)
I20151127-16:01:52.002(8)?     at accounts_server.js:462:32
I20151127-16:01:52.002(8)?     at tryLoginMethod (accounts_server.js:239:14)
I20151127-16:01:52.002(8)?     at AccountsServer.Ap._runLoginHandlers (accounts_server.js:459:18)
I20151127-16:01:52.002(8)?     at [object Object].methods.login (accounts_server.js:522:27)
I20151127-16:01:52.003(8)?     at maybeAuditArgumentChecks (livedata_server.js:1698:12)
I20151127-16:01:52.003(8)?     at livedata_server.js:708:19
I20151127-16:01:52.003(8)?     at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20151127-16:01:52.003(8)?     at livedata_server.js:706:40
I20151127-16:01:52.003(8)? Sanitized and reported to the client as: Match failed [400]

I found out it's because we're passing a string instead of a user object that's being checked.
https://github.com/meteor/meteor/blob/devel/packages/accounts-password/password_server.js#L244

I tried passing an object e.g
var loginRequest = {user: {username:'adminsample'}, password: password};

the error went away but it seems to not reach the server's Accounts.registerLoginHandler when I try to console.log(loginRequest).

It seems the error is due to different Accounts.registerLoginHandler process done in accounts_server and password_server in the meteor codebase and password_server's function will be used when accounts-password is added.

Hmmmmm STILL haven't figure out how to use both accounts-ui and accounts-password with custom authentication.

Wew.

@Micjoyce
Copy link

@byrne-yan How can you solve the process of sharing to me? I need you help

@byrne-yan
Copy link
Author

@mayinhosa @Micjoyce
Basic Idea is:
1.change to different key name when registerLoginHandler for phone to avoid conflicting with account_password. In phone_server.js:

Accounts.registerLoginHandler("phone", function (options) {
 -    if (!options.password || options.srp)
 +    if (!options.passwordEx || options.srp)
          return undefined; // don't handle           
      check(options, {  
          user    : userQueryValidator, 
 -        password: passwordValidator       
 +        passwordEx: passwordValidator
      });

2.In Meteor.loginWithPhoneAndPassword function, user's password passed in Accounts.callLoginMethod as the filed of paswordEx:

 +   if(selector.phone){
 +        args =
 +        {
 +            user: selector,
 +            passwordEx: Accounts._hashPassword(password)
 +        }
 +
 +    }
 +    Accounts.callLoginMethod({
 +        methodArguments: [args],

More details on my project:
byrne-yan@15a02a2

@psramkumar
Copy link

any update on this issue. did any one found the fix for this issue ?

@s4admin
Copy link

s4admin commented Jan 26, 2016

I have the same issue. Fixed by removing accounts-password, but that has other issues...

@ChenLi0830
Copy link

Tried the fix of @byrne-yan, and it worked!

To be more specific, here is what fixed the problem:

  1. Add the accounts-phone as a local package. In case you are relatively new to this, here is a pretty good article of how to do it.
  2. Remove the /dist folder (or alternatively you can probably re-run the /bundle-min.sh script once you finish step3 to override the /dist folder, I didn't try it though)
  3. Make the code change mentioned by @byrne-yan. The repository is forked to show the code change more clearly here

@chylvina
Copy link

just run

meteor remove accounts-password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants