views.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pyadselfservice 作者: kanayak123 项目源码 文件源码
def resetpass(request):
   getd = unquote(request.GET.get('key'))
   crypted_data = signer.unsign(getd, max_age=int(settings.PYADSELFSERVICE_STOUT))
   prim_key = {'username' : getd}
   if request.method == 'POST':
      form = passreset(request.POST)
      if form.is_valid():
         base32 = calc_base32(crypted_data)
         newpassword = form.cleaned_data['newpassword']
         confirmpassword = form.cleaned_data['confirmpassword']
         if newpassword and newpassword != confirmpassword:
            value = "Your New Password and Confirm Password did not match. Please go back and try again."
            return HttpResponseServerError(template.render(Context({'exception_value': value,})))
         else:
            output = do_reset(crypted_data, form.cleaned_data['confirmpassword'])
            if 'success' in output:
               value = str(output)
               return HttpResponseServerError(loader.get_template('success.html').render(Context({'exception_value': value,})))
            else:
               value = str(output)
               return HttpResponseServerError(template.render(Context({'exception_value': value,})))
      else:
         value = "Your new password does not comply with password policy. Please go back and try again."
         return HttpResponseServerError(template.render(Context({'exception_value': value,})))
   return render(request, 'resetpass.html', {'form': passreset(initial=prim_key)})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号