Mean.io - Best practice to extend User model

坚强是说给别人听的谎言 提交于 2019-12-07 03:32:27

I'm not sure qm69's solution would be the best for future compatibility with mean. In the mean.io documentation http://learn.mean.io/ it states the developer shouldn't alter any core packages, including the user package.

The mean.io pattern is to implement any and all extensions as a custom package. And override default views using the $viewPathProvider.override method.

Secondly the User package is fundamentally a security/authentication feature and not a profile implementation which regularly receives updates. Altering this will most likely break future fixes and risk introducing security bugs.

My advice would be to implement a profile using means package system and add a service dependency for the User service. I've done this in previous projects and it works well.

To implement a profile package, follow the below steps:

1) Create a custom package called profile using mean package profile.

2) Implement model/view/control for all profile requirements in the custom package. DONT ALTER ANYTHING IN THE USER package.

2) Use dependency injection to include the Global service service. This will give you access to Global.user data so you most likely don't even need to use the User services.

3) Override any User views using the $override method mentioned in the above doco.

Hope this helps ;)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!