Repository navigation
Auto-configure models required by app.enableAuth - #1323
Conversation
1960ee7 to
30e0580
Compare
There was a problem hiding this comment.
What's going to happen if these models are sub-classed?
There was a problem hiding this comment.
That's a good question. This shortcut is intended only for the simple situations where you typically don't create subclasses. To keep the implementation simple, I can modify the condition determining whether a base model should be attached or not, and do not attach a base model if there is a subclassed model already attached?
From user perspective, if you create let's say Customer extending User:
- If Customer is attached to a data source or the app, then the builtin User model is left unchanged.
- If Customer is not attached to the app nor the datasource, then we attach the builtin User model for you.
Thoughts?
app.enableAuthapp.enableAuth
app.enableAuthapp.enableAuth
|
@ritch @raymondfeng ping |
|
👍 |
When creating an application with a local registry, the default behaviour is to define only two core models Model & PersistedModel. The new flag `loadBuiltinModels` modifies this behaviour and instructs loopback to define all builtin models in the local registry too.
Modify `app.enableAuth` to automaticaly setup all required models
that are not attached to the app nor a datasource.
Users wishing to use this option must provide the name of the
data-source to use for these models.
Example usage:
var app = loopback();
app.dataSource('db', { connector: 'memory' });
app.enableAuth({ dataSource: 'db' });
app.use(loopback.rest());
app.listen(3000);
30e0580 to
3115e50
Compare
|
Reworked. @raymondfeng PTAL again. @ritch FYI, I have added a new |
Cool. We should start marking code like this somehow... so we can easily review it / modify it during major version changes. |
|
@slnode test please |
|
LGTM |
1 similar comment
|
LGTM |
…odels Auto-configure models required by `app.enableAuth`
Modify
app.enableAuthto automaticaly setup all required models that are not attached to the app nor a datasource.Users wishing to use this option must provide the name of the data-source to use for these models.
Example usage:
The purpose of this new API is to make it easier to setup authentication from code that does not use "slc loopback" project scaffolding, typically from unit-tests.
/to @ritch @raymondfeng please review