Commit 365cfd42 authored by Valentin Samir's avatar Valentin Samir

oops

parent 77fc5b59
......@@ -37,13 +37,13 @@ class UserCredential(forms.Form):
try:
user = models.User.objects.get(
username=auth.username,
session_key=self.request.session_key
session_key=self.request.session.session_key
)
user.save()
except models.User.DoesNotExist:
user = models.User.objects.create(
username=auth.username,
session_key=self.request.session_key
session_key=self.request.session.session_key
)
user.save()
else:
......
......@@ -61,10 +61,7 @@ class User(models.Model):
return utils.import_attr(settings.CAS_AUTH_CLASS)(self.username).attributs()
def __unicode__(self):
if self.session:
return u"%s - %s" % (self.username, self.session.session_key)
else:
return self.username
return u"%s - %s" % (self.username, self.session_key)
def logout(self, request=None):
"""Sending SLO request to all services the user logged in"""
......
......@@ -71,7 +71,7 @@ class LogoutMixin(object):
try:
user = models.User.objects.get(
username=self.request.session.get("username"),
session_key=self.request.session_key
session_key=self.request.session.session_key
)
user.logout(self.request)
user.delete()
......@@ -156,7 +156,7 @@ class LoginView(View, LogoutMixin):
if self.form.is_valid():
self.user = models.User.objects.get(
username=self.form.cleaned_data['username'],
session_key=self.request.session_key
session_key=self.request.session.session_key
)
request.session.set_expiry(0)
request.session["username"] = self.form.cleaned_data['username']
......@@ -263,7 +263,7 @@ class LoginView(View, LogoutMixin):
try:
self.user = models.User.objects.get(
username=self.request.session.get("username"),
session_key=self.request.session_key
session_key=self.request.session.session_key
)
except models.User.DoesNotExist:
self.logout()
......@@ -351,7 +351,7 @@ class Auth(View):
try:
user = models.User.objects.get(
username=form.cleaned_data['username'],
session_key=self.request.session_key
session_key=self.request.session.session_key
)
# is the service allowed
service_pattern = ServicePattern.validate(service)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment