Closed DenJohX closed 8 years ago
@DenJohX You either have to do your validation in hooks (which is what we prefer because it keeps you datastore agnostic) or write custom mongoose validations that are conditional. If you simply want to bring the email from the facebook profile top level then you always add a before
hook to your user service create
method.
We might make a change to the generator so that email and password aren't required by default but this is where the generator naturally starts to fall down. It's too hard to anticipate the requirements for every app so it'll probably have to be manual changes from here (ie. hooks or custom validators).
Changing you validations should allow you to continue on so I'm going to close this. If it doesn't work out then we can re-open and revisit. Thanks for reporting! đŸ˜„
Thanks for the guidance.
I'd ended up doing it all in a pre-save hook: obtaining the email from facebook and inserting it on the user, also generating a random password.
I'd leave the validation at model level, but yes, validation at service level seems to be the ideal.
Thanks again!
Im using a yeoman generated feathers app, with local and facebook authentication enabled.
The authentication service is as follows:
The user model:
The local authentication works fine, but facebook does not, When the callback its called, the new user does not gets created because the validation fails with:
The validation is there for new local user accounts, but should not work with facebook or others. Is there a way to configure this behavior? perhaps using the adquired email from facebook and a random generated password to create the new accounts.