gadelkareem / sails-dynamodb

Amazon DynamoDB adapter for Waterline / Sails.js
http://sailsjs.org
46 stars 22 forks source link

Authenticating via Facebook Login is giving an error #41

Closed kidsil closed 7 years ago

kidsil commented 7 years ago

When trying to login via Facebook (using passport-facebook) I'm getting the following error:

Error: the value of id is not allowed to be undefined

This doesn't happen when using mongodb, so it must have something to do with IDs not being automatically generated, I'm not entirely sure though.

ferrants commented 7 years ago

I don't think sails-dynamodb is generating any IDs. mongo has mongo ids, dynamodb doesn't have that

kidsil commented 7 years ago

So the main question is what should I modify on the User.js Model to make Facebook login work (I've tried autoIncrement and similar things, sadly it still won't work)

ferrants commented 7 years ago

I'd do something that will set an id like this: User.js

module.exports = {

  connection: 'dynamodb',
  autoPK: false,

  attributes: {
    id:             'string',
  },
  beforeCreate: function(values, cb) {
    values.id = values.id || generateRandomId();
    return cb();
  }
kidsil commented 7 years ago

Details: ValidationException: One or more parameter values were invalid: Type mismatch for key id expected: N actual: S

kidsil commented 7 years ago

Never mind I think I had to clear my localhost cookies...

I used uuid.v4() instead of generateRandomId()