dot*_*tty 0 python authentication django
干草我想知道是否有人知道更好的方法来做到这一点.
def login_user(request):
username = request.POST.get('username')
password = request.POST.get('password')
user = User.objects.filter(username=username)
if user:
user = user[0]
if user.password == generate_password(password):
return HttpResponse("password fine")
else:
return HttpResponse("password incorrect")
else:
return HttpResponse("no user found by that username")
Run Code Online (Sandbox Code Playgroud)
而generate_password函数就是
generate_password(string):
return hashlib.sha224(str(string)).hexdigest()
Run Code Online (Sandbox Code Playgroud)
任何想法都会很棒.
谢谢
为什么不使用Django auth默认视图?
| 归档时间: |
|
| 查看次数: |
455 次 |
| 最近记录: |