1 Star 0 Fork 0

宅蓝三木/registration

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
signals.py 807 Bytes
一键复制 编辑 原始数据 按行查看 历史
Wang Sen 提交于 2015-02-06 00:09 +08:00 . init
from django.conf import settings
from django.contrib.auth import login, get_backends
from django.dispatch import Signal
# A new user has registered.
user_registered = Signal(providing_args=["user", "request"])
# A user has activated his or her account.
user_activated = Signal(providing_args=["user", "request"])
def login_user(sender, user, request, **kwargs):
""" Automatically authenticate the user when activated """
if getattr(settings, 'REGISTRATION_AUTO_LOGIN', False ):
backend = get_backends()[0] # Hack to bypass `authenticate()`.
user.backend = "%s.%s" % (backend.__module__, backend.__class__.__name__)
login(request, user)
request.session['REGISTRATION_AUTO_LOGIN'] = True
request.session.modified = True
user_activated.connect(login_user)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wangsen/registration.git
git@gitee.com:wangsen/registration.git
wangsen
registration
registration
master

搜索帮助