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

Feathers Auth Configuration Error #12

Closed
lokenx opened this Issue Nov 21, 2015 · 8 comments

Comments

Projects
None yet
3 participants
@lokenx
Copy link

lokenx commented Nov 21, 2015

Using the example in the README I get the below error:

.configure(feathersAuth({
             ^

TypeError: feathersAuth is not a function
    at Object.<anonymous> (/Users/mdelport/Development/node/plexauth/index.js:17:14)
    at Module._compile (module.js:425:26)
    at Object.Module._extensions..js (module.js:432:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:457:10)
    at startup (node.js:136:18)
    at node.js:972:3

Not sure if I'm missing something or if the build is just currently broken.

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Nov 22, 2015

Thanks for spotting this. After updating to ES6 imports, internally, you have to add .default to the require()

var feathersAuth = require('feathers-authentication').default;
@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Nov 22, 2015

@daffl @ekryski Is there a way to work around having to add .default to the require?

@lokenx

This comment has been minimized.

Copy link
Author

lokenx commented Nov 22, 2015

Doing that causes it to crash on

var hashPassword = feathersAuth.hashPassword;

var userService = app.service('/api/users');

userService.before({
  create: hashPassword()
});

//// ERROR ////
TypeError: hashPassword is not a function
@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Nov 22, 2015

Oh, yep. Those moved, too. I'll update the docs.

Do this instead:

var authHooks = require('feathers-authentication').hooks;

var userService = app.service('/api/users');
userService.before({
  // If your password field is just "password", you can do this.
  create: authHooks.hashPassword
  // You can also customize the password field if you need to.
  create: authHooks.hashPassword('pass')
});
@lokenx

This comment has been minimized.

Copy link
Author

lokenx commented Nov 22, 2015

That seems to work, I'll have to play more tomorrow! Thanks for speedy responses, probably safe to close.

@daffl

This comment has been minimized.

Copy link
Member

daffl commented Nov 22, 2015

@marshallswain I started doing export default module.exports = xyz;

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Nov 22, 2015

@lokenx Cool. No problem. I haven't added documentation for all of the hooks to the README.md, yet, but you can browse through them in the code. feathers-authentication ONLY takes care of auth. You'll need to use hooks for access control. I'll get a full example in place sometime soon. There might be a similar example on feathersjs.com, already.

@marshallswain

This comment has been minimized.

Copy link
Member

marshallswain commented Nov 22, 2015

@daffl thanks.

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.