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

authentication dance

This commit is contained in:
Alexis Metaireau 2011-08-21 22:20:50 +02:00
parent 16fcfd284e
commit 63777c16bc
2 changed files with 8 additions and 9 deletions

View file

@ -1,6 +1,6 @@
Hi, Hi,
Someone using the email adress {{ g.project.contact_email }} invited you to share your expenses for {{ g.project.name }} on our application. Someone using the email adress {{ g.project.contact_email }} invited you to share your expenses for "{{ g.project.name }}".
It's as simple as saying what did you paid for, for who, and how much did it cost you, we are caring about the rest. It's as simple as saying what did you paid for, for who, and how much did it cost you, we are caring about the rest.

View file

@ -47,13 +47,14 @@ def pull_project(endpoint, values):
else: else:
# redirect to authentication page # redirect to authentication page
raise RequestRedirect( raise RequestRedirect(
url_for("authenticate", redirect_url=request.url, url_for("authenticate", project_id=project_id))
project_id=project_id))
@app.route("/authenticate", methods=["GET", "POST"]) @app.route("/authenticate", methods=["GET", "POST"])
def authenticate(redirect_url=None, project_id=None): def authenticate(project_id=None):
form = AuthenticationForm() form = AuthenticationForm()
project_id = form.id.data or request.args['project_id'] if not form.id.data and request.args['project_id']:
form.id.data = request.args['project_id']
project_id = form.id.data
project = Project.query.get(project_id) project = Project.query.get(project_id)
create_project = False # We don't want to create the project by default create_project = False # We don't want to create the project by default
if not project: if not project:
@ -65,8 +66,7 @@ def authenticate(redirect_url=None, project_id=None):
# if credentials are already in session, redirect # if credentials are already in session, redirect
if project_id in session and project.password == session[project_id]: if project_id in session and project.password == session[project_id]:
setattr(g, 'project', project) setattr(g, 'project', project)
redirect_url = redirect_url or url_for("list_bills") return redirect(url_for("list_bills"))
return redirect(redirect_url)
# else process the form # else process the form
if request.method == "POST": if request.method == "POST":
@ -82,8 +82,7 @@ def authenticate(redirect_url=None, project_id=None):
session[project_id] = form.password.data session[project_id] = form.password.data
session.update() session.update()
setattr(g, 'project', project) setattr(g, 'project', project)
redirect_url = redirect_url or url_for("list_bills") return redirect(url_for("list_bills"))
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)