Skip to content
This repository was archived by the owner on Apr 23, 2019. It is now read-only.

How to input extra fields along with email/password to server by local strategy? #96

Closed
flight9 opened this issue Apr 1, 2018 · 2 comments

Comments

@flight9
Copy link

flight9 commented Apr 1, 2018

I'm using authentication-client and local strategy and socket.io like example code:

app.authenticate({
  strategy: 'local',
  email: 'my@email.com',
  password: 'my-password'
}).then(() => {
  // Logged in
}).catch(e => {
  // Show login page (potentially with `e.message`)
  console.error('Authentication error', e);
});

Expected

I would like to input some extra fields along with email/password (eg. captcha or openid to bind with the user) into authenticate() to send to server to authenticate or save to db, but it seems no mechanism for thar purpose.
How can I do this?

@daffl
Copy link
Member

daffl commented Apr 1, 2018

You can send any fields you want and use them on the /authentication in a hook:

app.service('/authentication').hooks({
  before: {
    create(context) {
      // context.data
    }
  }
});

The fields that are being used depend on the strategy. The local strategy only takes a username and password.

@flight9
Copy link
Author

flight9 commented Apr 2, 2018

Thanks @daffl . I can get those fields from context.data in before/after create hooks.

Later, I got stuck on another question on server site: feathersjs-ecosystem/authentication#659
Hope u can give me more suggestions, thanks.

@flight9 flight9 closed this as completed Apr 2, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants