Rad*_*Hex 6 python django django-models django-admin django-authentication
我试图弄清楚如何使用其他功能增强authenticate方法.
例如
这个网站的前端非常简单,但管理面板呢?
我估计我应该覆盖User的Manager对象,因为authenticate可能存在于那里.我觉得这很难理解.
提前致谢!:)
您可以按照http://docs.djangoproject.com/en/dev/topics/auth/#authentication-backends中的说明创建自定义身份验证后端.基本上,您创建一个具有authenticate方法的后端类:
class MyBackend:
def authenticate(self, username=None, password=None):
# Check the username/password and return a User.
Run Code Online (Sandbox Code Playgroud)
然后将该类添加到AUTHENTICATION_BACKENDS在settings.py.
虽然这是进行身份验证,你可以做所有你通过重定向用户到修改密码页面,如果密码是正确的,但过期,比如简单地提到的密码验证的东西.考虑使用消息传递框架为用户提供有关将其指向通用更改密码页面时发生的事情的提示.
| 归档时间: |
|
| 查看次数: |
2450 次 |
| 最近记录: |