related to this: previous issue
I have this model defined:
var customer = mongoDev.createModel('customer',
{
id: {
type: String,
id: true
},
firstName: String,
lastName: String,
badge: String,
email: String
},
{
strict: true,
base: "User"
});
If I do nothing else, I get all the extra user endpoints I expected (login, logout, accessTokens, etc). However my result from a login gives me:
{
"id": "ssOzK8EswH...",
"ttl": 1209600,
"created": "...",
"userId": "53c6f5d4769ed..."
}
Seems like userId should be customerId. I have removed the user & accessToken models from models.json. So I don't even know where it's getting the relationship info, unless it's baked in somewhere. Anyway if I try to call /customer/53c6f5d4769ed...
and supply the token in the header I get a 401. Technically the Id is correct, just wrong FK name.
I've tried things like
var accessToken = mongoDev.createModel('accessToken',{},{base: "AccessToken"});
accessToken.belongsTo(customer, {as: 'customer', foreignKey: 'customerId'});
I think this changed the FK name for me, but I still got 401's when calling followup endpoints.
This is where I got on my own. So my question is actually this:
Using code-first and not using the 'user' model for my authN how do I wired up the accessToken (also code-first)? And the twist would be I would plan to have multiple authN models (i.e. customer, vendor, employee). So the real question is how do I wire this to allow each type of 'user' to get their own accessTokens???
Clear as mud?? ;-)