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)})
评论列表
文章目录