Create a signal that associates a user with an application
This commit is contained in:
0
scim_app/core/__init__.py
Normal file
0
scim_app/core/__init__.py
Normal file
3
scim_app/core/admin.py
Normal file
3
scim_app/core/admin.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
14
scim_app/core/apps.py
Normal file
14
scim_app/core/apps.py
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
from django.db.models.signals import post_save
|
||||||
|
|
||||||
|
|
||||||
|
from . import signals
|
||||||
|
|
||||||
|
class CoreConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'core'
|
||||||
|
|
||||||
|
def ready(self) -> None:
|
||||||
|
from oauth2_provider.models import get_access_token_model
|
||||||
|
TokenModel = get_access_token_model()
|
||||||
|
post_save.connect(signals.set_user_on_application_token, sender=TokenModel)
|
0
scim_app/core/migrations/__init__.py
Normal file
0
scim_app/core/migrations/__init__.py
Normal file
3
scim_app/core/models.py
Normal file
3
scim_app/core/models.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
5
scim_app/core/signals.py
Normal file
5
scim_app/core/signals.py
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
def set_user_on_application_token(sender, **kwargs):
|
||||||
|
instance = kwargs['instance']
|
||||||
|
if kwargs['created'] and not instance.user:
|
||||||
|
instance.user = sender.user.get_queryset().first()
|
||||||
|
instance.save()
|
3
scim_app/core/tests.py
Normal file
3
scim_app/core/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
scim_app/core/views.py
Normal file
3
scim_app/core/views.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
@@ -43,6 +43,8 @@ INSTALLED_APPS = [
|
|||||||
|
|
||||||
'django_scim',
|
'django_scim',
|
||||||
'oauth2_provider',
|
'oauth2_provider',
|
||||||
|
|
||||||
|
'core',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
Reference in New Issue
Block a user