获取django用户后如何手动验证? [英] How to manually authenticate after get django user?
本文介绍了获取django用户后如何手动验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
user = User.objects.get(email = email)
user = authenticate(username = user.username, password = user.password)
登录(请求,用户)
有另一种方法实现这个?
解决方案
如果你这样做,你不需要先验证()(但是我没有告诉你!):
user.backend ='django.contrib.auth.backends.ModelBackend'
登录(请求,用户)
Im writing a facebook-connect app that login user after authenticate session on facebook, question is how can i authenticate user on django after get user object?
user = User.objects.get(email=email)
user = authenticate(username=user.username, password=user.password)
login(request, user)
Is there another way to achieve this ?
解决方案
You don't actually need to authenticate() first if you do this (but I didn't tell you!):
user.backend = 'django.contrib.auth.backends.ModelBackend'
login(request, user)
这篇关于获取django用户后如何手动验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文