Django default user permissions

霸气de小男生 提交于 2019-12-24 18:12:11

问题


Is it possible to give a user default permissions for a specific app, right after creation?

There is a similar question here, but since it is 1,5 years old I hope, there is a possibility to do it now.

The background is the following:

I only run one app in my Djangopage. Let's call it 'foo'.
My users log into the admin-page with their LDAP Account. If they log in the first time, their account isn't in the database and will be created. When they are logged in then, they can't do anything, because they don't have any permissions. I want to give them all permissions for my 'foo' App, right after account-creation. At the moment, I need to log in with an adminaccount and grant them manually.


回答1:


If you're using the RemoteUserBackend authentication backend with LDAP, then you could subclass it, override the configure_user method and set the permission there.

If you're using a different method to authenticate, then you can use the post_save signal.



来源:https://stackoverflow.com/questions/20992334/django-default-user-permissions

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