Commit ba986638 authored by Vincent Le gallic's avatar Vincent Le gallic
Browse files

Réindentation

parent 976c50d4
......@@ -97,56 +97,55 @@ def logout(request):
return HttpResponseRedirect(settings.NOTE_LOGIN_URL)
def regen_pw(request, token):
variables = {}
if token:
if request.method == "POST":
form = forms.PasswordForm(request.POST, label_suffix=" :")
if form.is_valid():
try:
sock = nk.connect_NK(request)
except nk.NKError as exc:
return nk.gerer_NKError(request, exc)
new_pass= form.cleaned_data["password"]
data = [token, new_pass]
sock.write(json.dumps(["confirm_reset_password", data]))
out = nk.full_read(sock)
errors = out["errmsg"]
if errors:
messages.add_error(request, errors)
else:
messages.add_success(request, out["msg"])
else:
form = forms.PasswordForm(label_suffix=" :")
variables["NOTE_ROOT_URL"] = settings.NOTE_ROOT_URL
variables["NOTE_LOGIN_URL"] = settings.NOTE_LOGIN_URL
variables["form"] = form
return render(request, "note/regen_pw.html", variables)
else :
if request.method == "POST":
form = forms.Regen_pwForm(request.POST, label_suffix=" :")
if form.is_valid():
try:
sock = nk.connect_NK(request)
except nk.NKError as exc:
return nk.gerer_NKError(request, exc)
nom = form.cleaned_data["nom"]
prenom = form.cleaned_data["prenom"]
mail = form.cleaned_data["mail"]
data = [prenom,nom,mail]
sock.write(json.dumps(["generate_reset_password", data]))
out = nk.full_read(sock)
errors = out["errmsg"]
if errors:
messages.add_error(request, errors)
else:
messages.add_success(request, out["msg"])
else:
form = forms.Regen_pwForm(label_suffix=" :")
variables["NOTE_ROOT_URL"] = settings.NOTE_ROOT_URL
variables["NOTE_LOGIN_URL"] = settings.NOTE_LOGIN_URL
variables["form"] = form
return render(request, "note/ask_regen_pw.html", variables)
variables = {}
if token:
if request.method == "POST":
form = forms.PasswordForm(request.POST, label_suffix=" :")
if form.is_valid():
try:
sock = nk.connect_NK(request)
except nk.NKError as exc:
return nk.gerer_NKError(request, exc)
new_pass = form.cleaned_data["password"]
data = [token, new_pass]
sock.write(json.dumps(["confirm_reset_password", data]))
out = nk.full_read(sock)
errors = out["errmsg"]
if errors:
messages.add_error(request, errors)
else:
messages.add_success(request, out["msg"])
else:
form = forms.PasswordForm(label_suffix=" :")
variables["NOTE_ROOT_URL"] = settings.NOTE_ROOT_URL
variables["NOTE_LOGIN_URL"] = settings.NOTE_LOGIN_URL
variables["form"] = form
return render(request, "note/regen_pw.html", variables)
else :
if request.method == "POST":
form = forms.Regen_pwForm(request.POST, label_suffix=" :")
if form.is_valid():
try:
sock = nk.connect_NK(request)
except nk.NKError as exc:
return nk.gerer_NKError(request, exc)
nom = form.cleaned_data["nom"]
prenom = form.cleaned_data["prenom"]
mail = form.cleaned_data["mail"]
data = [prenom,nom,mail]
sock.write(json.dumps(["generate_reset_password", data]))
out = nk.full_read(sock)
errors = out["errmsg"]
if errors:
messages.add_error(request, errors)
else:
messages.add_success(request, out["msg"])
else:
form = forms.Regen_pwForm(label_suffix=" :")
variables["NOTE_ROOT_URL"] = settings.NOTE_ROOT_URL
variables["NOTE_LOGIN_URL"] = settings.NOTE_LOGIN_URL
variables["form"] = form
return render(request, "note/ask_regen_pw.html", variables)
@standard_page
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment