1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ihatemoney_ynh.git synced 2024-09-03 19:26:15 +02:00

fixes authentication (#9)

This commit is contained in:
Alexis Metaireau 2011-08-09 19:28:50 +02:00
parent 78914962ed
commit bdbc6361b9

View file

@ -35,24 +35,25 @@ def authenticate(redirect_url=None):
# propose him a link to the creation form. # propose him a link to the creation form.
create_project = project_id create_project = project_id
# if credentials are already in session, redirect else:
if project_id in session and project.password == session[project_id]: # if credentials are already in session, redirect
return redirect(redirect_url) if project_id in session and project.password == session[project_id]:
return redirect(redirect_url)
# else process the form # else process the form
if project and request.method == "POST": if request.method == "POST":
if form.validate(): if form.validate():
if not form.password.data == project.password: if not form.password.data == project.password:
form.errors['password'] = ["The password is not the right one"] form.errors['password'] = ["The password is not the right one"]
else: else:
# maintain a list of visited projects # maintain a list of visited projects
if "projects" not in session: if "projects" not in session:
session["projects"] = [] session["projects"] = []
# add the project on the top of the list # add the project on the top of the list
session["projects"].insert(0, (project_id, project.name)) session["projects"].insert(0, (project_id, project.name))
session[project_id] = form.password.data session[project_id] = form.password.data
session.update() session.update()
return redirect(redirect_url) return redirect(redirect_url)
return render_template("authenticate.html", form=form, return render_template("authenticate.html", form=form,
create_project=create_project) create_project=create_project)