帐户不活动页面在Django-Allauth中不起作用
我已经使用流行的Django-Allauth软件包成功设置了使用Django应用程序的身份验证系统。我通过更新hespendeduser.is_active = false
暂停了注册用户正确。。 我是否需要任何特殊的配置来显示account_inactive.html
模板,因为我找不到在官方文档中提到的任何内容?
注意: django-allauth版本为0.49.0,django版本为4.0.3
I have successfully setup an authentication system with django application using the popular django-allauth package. I suspended a registered user by updating SuspendedUser.is_active=False
but whenever I try to login as the suspended user I'd get the failed authentication message The username and/or password you specified are not correct.
.
Do I need any special configuration to display the account_inactive.html
template as I cannot find anything that mentions that in the official documentation?.
Note: django-allauth version is 0.49.0 and django version is 4.0.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以覆盖Django-Allauth的登录功能。您可以在用户模型名称下创建一个dield
is_suspended
,而不是给出is_Active = false
。在登录函数中,登录()放置一个if语句。渲染(请求,'user/user_policy.html'{'messages':message})
或搜索 django-alluth信号
You can override log-in function of django-allauth. And you can create a dield under your user model names
is_suspended
instead of givingis_active=False
. And in login function before login() put an if statement.render(request, 'user/user_policy.html' {'message':message})
or search django-alluth signals
在查看配置后,我意识到我在
settings.py
文件中使用了自定义身份验证后端。 django-allauth需要allauth.account.auth_backends.authenticationbackend
来处理身份验证和权限。将其添加到我的项目配置中解决了该问题,
尽管在
After reviewing my configurations, I realized I was using a custom authentication backend in my
settings.py
file. django-allauth requiresallauth.account.auth_backends.AuthenticationBackend
to handle authentication and permissions.Adding this to my project config solved the problem
Although it was stated in the docs