summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerghei Mihai <smihai@entrouvert.com>2015-06-01 16:53:16 (GMT)
committerSerghei Mihai <smihai@entrouvert.com>2015-06-01 16:53:16 (GMT)
commit30af3088bc67a0bbb12ba67ac2d668500dc9e779 (patch)
tree883f79b22ddbd8a61a0a0e4c9553c06ee041451e
parent75a981d9282fffd78995d231d1f82a0cf3a2a3a5 (diff)
downloadu-auth-30af3088bc67a0bbb12ba67ac2d668500dc9e779.zip
u-auth-30af3088bc67a0bbb12ba67ac2d668500dc9e779.tar.gz
u-auth-30af3088bc67a0bbb12ba67ac2d668500dc9e779.tar.bz2
raise 404 error if organization doesn't exit
-rw-r--r--uauth/views.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/uauth/views.py b/uauth/views.py
index 726c61f..26d0929 100644
--- a/uauth/views.py
+++ b/uauth/views.py
@@ -5,7 +5,7 @@ from xml.etree import ElementTree
from django.views.generic.base import TemplateView
from django.views.generic import FormView
from django.views.decorators.csrf import csrf_exempt
-from django.shortcuts import render_to_response
+from django.shortcuts import render_to_response, get_object_or_404
from django.core import signing
from django.http.request import QueryDict
from django.contrib.auth import authenticate
@@ -75,8 +75,9 @@ class OrganizationPageView(LoginMixin, FormView):
def get_context_data(self, **kwargs):
context = super(OrganizationPageView, self).get_context_data(**kwargs)
+ organization = get_object_or_404(Organization,
+ slug=self.kwargs['organization_slug'])
idps = get_idp_list()
- organization = Organization.objects.get(slug=self.kwargs['organization_slug'])
self.request.session['organization'] = organization.slug
self.request.session[organization.slug] = self.request.GET.urlencode()
relay = signing.dumps({'organization': organization.slug})
@@ -90,7 +91,8 @@ class OrganizationPageView(LoginMixin, FormView):
def form_valid(self, form):
data = form.cleaned_data
- organization = Organization.objects.get(slug=self.kwargs['organization_slug'])
+ organization = get_object_or_404(Organization,
+ slug=self.kwargs['organization_slug'])
data.update({'organization': organization})
user = authenticate(**data)
if user: