From 34ccb3546d2d1cb15e3bc4f5524a2c7630dc2182 Mon Sep 17 00:00:00 2001 From: Arnaud Bos Date: Wed, 14 Sep 2011 02:07:26 +0200 Subject: [PATCH 1/2] Validate authentication form if given identifier is null. Fix #30. --- budget/web.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/budget/web.py b/budget/web.py index 5667b056..3527a75c 100644 --- a/budget/web.py +++ b/budget/web.py @@ -63,7 +63,7 @@ def pull_project(endpoint, values): def authenticate(project_id=None): """Authentication form""" form = AuthenticationForm() - if not form.id.data and request.args['project_id']: + if not form.id.data and request.args.get('project_id'): form.id.data = request.args['project_id'] project_id = form.id.data project = Project.query.get(project_id) @@ -71,7 +71,11 @@ def authenticate(project_id=None): if not project: # But if the user try to connect to an unexisting project, we will # propose him a link to the creation form. - create_project = project_id + if not project_id: + if request.method == "POST": + form.validate() + else: + create_project = project_id else: # if credentials are already in session, redirect From 6212b643ec97e5708a1dc5af39e3f9eb35c01405 Mon Sep 17 00:00:00 2001 From: Arnaud Bos Date: Wed, 14 Sep 2011 02:19:10 +0200 Subject: [PATCH 2/2] Simplified #30 fix. --- budget/web.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/budget/web.py b/budget/web.py index 3527a75c..73761357 100644 --- a/budget/web.py +++ b/budget/web.py @@ -71,9 +71,8 @@ def authenticate(project_id=None): if not project: # But if the user try to connect to an unexisting project, we will # propose him a link to the creation form. - if not project_id: - if request.method == "POST": - form.validate() + if request.method == "POST": + form.validate() else: create_project = project_id