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

Allow multiple username fields #148

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
4 participants
@sdbondi
Copy link

commented Nov 3, 2016

Usage:

options.usernameFields = ['username', 'user[email]', 'email'];

Defaults to ['username']

This allows the lookup to find for e.g. an email or username and pass
that to the strategy verify function.

Stan Bondi
Allow multiple username fields
sage:

options.usernameFields = ['username', 'user[email]', 'email'];

Defaults to ['username']

This allows the lookup to find for e.g. an email or username and pass
that to the strategy verify function.
@coveralls

This comment has been minimized.

Copy link

commented Nov 3, 2016

Coverage Status

Coverage increased (+2.4%) to 100.0% when pulling 5b4b4bb on fixate:feature/multipleusernames into 3b9980f on jaredhanson:master.

@jaredhanson

This comment has been minimized.

Copy link
Owner

commented Nov 3, 2016

What's the use case for this? The submitted form has a single key, why would the strategy itself not be in sync with that?

@ekryski

This comment has been minimized.

Copy link

commented Nov 18, 2016

I'll chime in and say that I'm not sure this is needed. @sdbondi regarding Feathers the new Auth 1.0.0-alpha allows you to register strategies the same way you would passport so you can have custom strategies.

Furthermore, you can register multiple local strategies with different username fields as options and chain them. Here's how you would accomplish that with the new feathers-authentication-local plugin.

// On the server
app.configure(auth({ secret: 'super secret' }))
  .configure(local()) // defaults usernameField to 'email'
  .configure(local({ // support username
    name: 'local-username',
    usernameField: 'username'
  }));

app.service('authentication').hooks({
  before: {
    create: auth.hooks.authenticate(['local', 'local-username'])
  }
});

// On the client

// for email
app.authenticate({
  strategy: 'local',
  email: 'me@mydomain.com',
  password: 'password'
}).then(...);

// username
app.authenticate({
  strategy: 'local-username',
  username: 'hulkhogan23',
  password: 'password'
}).then(...);

@jaredhanson my personal opinion is that you could close this but I'll leave that for you two to discuss. 🍻

@sdbondi

This comment has been minimized.

Copy link
Author

commented Nov 18, 2016

@jaredhanson I see your point, the use case is probably too specific - we have two forms, one with a username, one with an email address but they submit to the same endpoint.

@ekryski Thanks, I'll definitely make use of the decoupled version of feathers-auth when I get a chance - that does indeed make this unnecessary 👍

I'll close this.

@sdbondi sdbondi closed this Nov 18, 2016

@ekryski

This comment has been minimized.

Copy link

commented Nov 18, 2016

Sounds good @sdbondi. I'm just wrapping up the auth client right now and publishing the new permissions and all the new pieces should be ready to try out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.