oops
This commit is contained in:
parent
77fc5b5988
commit
365cfd4279
3 changed files with 7 additions and 10 deletions
|
@ -37,13 +37,13 @@ class UserCredential(forms.Form):
|
||||||
try:
|
try:
|
||||||
user = models.User.objects.get(
|
user = models.User.objects.get(
|
||||||
username=auth.username,
|
username=auth.username,
|
||||||
session_key=self.request.session_key
|
session_key=self.request.session.session_key
|
||||||
)
|
)
|
||||||
user.save()
|
user.save()
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
user = models.User.objects.create(
|
user = models.User.objects.create(
|
||||||
username=auth.username,
|
username=auth.username,
|
||||||
session_key=self.request.session_key
|
session_key=self.request.session.session_key
|
||||||
)
|
)
|
||||||
user.save()
|
user.save()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -61,10 +61,7 @@ class User(models.Model):
|
||||||
return utils.import_attr(settings.CAS_AUTH_CLASS)(self.username).attributs()
|
return utils.import_attr(settings.CAS_AUTH_CLASS)(self.username).attributs()
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
if self.session:
|
return u"%s - %s" % (self.username, self.session_key)
|
||||||
return u"%s - %s" % (self.username, self.session.session_key)
|
|
||||||
else:
|
|
||||||
return self.username
|
|
||||||
|
|
||||||
def logout(self, request=None):
|
def logout(self, request=None):
|
||||||
"""Sending SLO request to all services the user logged in"""
|
"""Sending SLO request to all services the user logged in"""
|
||||||
|
|
|
@ -71,7 +71,7 @@ class LogoutMixin(object):
|
||||||
try:
|
try:
|
||||||
user = models.User.objects.get(
|
user = models.User.objects.get(
|
||||||
username=self.request.session.get("username"),
|
username=self.request.session.get("username"),
|
||||||
session_key=self.request.session_key
|
session_key=self.request.session.session_key
|
||||||
)
|
)
|
||||||
user.logout(self.request)
|
user.logout(self.request)
|
||||||
user.delete()
|
user.delete()
|
||||||
|
@ -156,7 +156,7 @@ class LoginView(View, LogoutMixin):
|
||||||
if self.form.is_valid():
|
if self.form.is_valid():
|
||||||
self.user = models.User.objects.get(
|
self.user = models.User.objects.get(
|
||||||
username=self.form.cleaned_data['username'],
|
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.set_expiry(0)
|
||||||
request.session["username"] = self.form.cleaned_data['username']
|
request.session["username"] = self.form.cleaned_data['username']
|
||||||
|
@ -263,7 +263,7 @@ class LoginView(View, LogoutMixin):
|
||||||
try:
|
try:
|
||||||
self.user = models.User.objects.get(
|
self.user = models.User.objects.get(
|
||||||
username=self.request.session.get("username"),
|
username=self.request.session.get("username"),
|
||||||
session_key=self.request.session_key
|
session_key=self.request.session.session_key
|
||||||
)
|
)
|
||||||
except models.User.DoesNotExist:
|
except models.User.DoesNotExist:
|
||||||
self.logout()
|
self.logout()
|
||||||
|
@ -351,7 +351,7 @@ class Auth(View):
|
||||||
try:
|
try:
|
||||||
user = models.User.objects.get(
|
user = models.User.objects.get(
|
||||||
username=form.cleaned_data['username'],
|
username=form.cleaned_data['username'],
|
||||||
session_key=self.request.session_key
|
session_key=self.request.session.session_key
|
||||||
)
|
)
|
||||||
# is the service allowed
|
# is the service allowed
|
||||||
service_pattern = ServicePattern.validate(service)
|
service_pattern = ServicePattern.validate(service)
|
||||||
|
|
Loading…
Reference in a new issue