Revision 30af3088
Added by Serghei Mihai almost 10 years ago
uauth/views.py | ||
---|---|---|
5 | 5 |
from django.views.generic.base import TemplateView |
6 | 6 |
from django.views.generic import FormView |
7 | 7 |
from django.views.decorators.csrf import csrf_exempt |
8 |
from django.shortcuts import render_to_response |
|
8 |
from django.shortcuts import render_to_response, get_object_or_404
|
|
9 | 9 |
from django.core import signing |
10 | 10 |
from django.http.request import QueryDict |
11 | 11 |
from django.contrib.auth import authenticate |
... | ... | |
75 | 75 |
|
76 | 76 |
def get_context_data(self, **kwargs): |
77 | 77 |
context = super(OrganizationPageView, self).get_context_data(**kwargs) |
78 |
organization = get_object_or_404(Organization, |
|
79 |
slug=self.kwargs['organization_slug']) |
|
78 | 80 |
idps = get_idp_list() |
79 |
organization = Organization.objects.get(slug=self.kwargs['organization_slug']) |
|
80 | 81 |
self.request.session['organization'] = organization.slug |
81 | 82 |
self.request.session[organization.slug] = self.request.GET.urlencode() |
82 | 83 |
relay = signing.dumps({'organization': organization.slug}) |
... | ... | |
90 | 91 |
|
91 | 92 |
def form_valid(self, form): |
92 | 93 |
data = form.cleaned_data |
93 |
organization = Organization.objects.get(slug=self.kwargs['organization_slug']) |
|
94 |
organization = get_object_or_404(Organization, |
|
95 |
slug=self.kwargs['organization_slug']) |
|
94 | 96 |
data.update({'organization': organization}) |
95 | 97 |
user = authenticate(**data) |
96 | 98 |
if user: |
Also available in: Unified diff
raise 404 error if organization doesn't exit