Skip to content

Commit

Permalink
@paradxum requested changes -- signals.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ralequi committed Oct 22, 2021
1 parent ea5061a commit 605447e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
14 changes: 12 additions & 2 deletions simple_sso/sso_client/models.py → simple_sso/signals.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@

from simple_sso.settings import settings
from django.urls import NoReverseMatch, reverse

from simple_sso.settings import settings
from simple_sso.sso_server.models import Token
from webservices.sync import SyncConsumer


def logout_token(sender, request, **kwargs):
"""
A signal receiver which removes a token when its users logs out.
"""
tokens = Token.objects.select_related('session').filter(session__session_key=request.session.session_key)

for token in tokens:
token.delete()


def logout_sso_client(sender, request, user, **kwargs):
"""
A signal receiver which notifies the server when the client have logged out.
Expand Down
2 changes: 1 addition & 1 deletion simple_sso/sso_client/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class SimpleSSOClient(AppConfig):
name = 'simple_sso.sso_client'

def ready(self):
from .models import logout_sso_client
from simple_sso.signals import logout_sso_client
user_logged_out.connect(
logout_sso_client, dispatch_uid='logout_sso_client')
2 changes: 1 addition & 1 deletion simple_sso/sso_server/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ class SimpleSSOServer(AppConfig):
name = 'simple_sso.sso_server'

def ready(self):
from .models import logout_token
from simple_sso.signals import logout_token
user_logged_out.connect(logout_token, dispatch_uid='logout_token')
10 changes: 0 additions & 10 deletions simple_sso/sso_server/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ def rotate_keys(self):
self.save()


def logout_token(sender, request, **kwargs):
"""
A signal receiver which removes a token when its users logs out.
"""
tokens = Token.objects.select_related('session').filter(session__session_key=request.session.session_key)

for token in tokens:
token.delete()


class Token(models.Model):
consumer = models.ForeignKey(
Consumer,
Expand Down

0 comments on commit 605447e

Please sign in to comment.