is staff
This commit is contained in:
parent
21b338b256
commit
4bfc6c2f22
@ -12,5 +12,6 @@ urlpatterns = [
|
|||||||
path(*LogoutView.as_path()),
|
path(*LogoutView.as_path()),
|
||||||
path(*PingView.as_path()),
|
path(*PingView.as_path()),
|
||||||
path(*VKAuthView.as_path()),
|
path(*VKAuthView.as_path()),
|
||||||
path(*YandexAuthView.as_path())
|
path(*YandexAuthView.as_path()),
|
||||||
|
path('is_staff', is_staff)
|
||||||
]
|
]
|
||||||
|
@ -7,3 +7,4 @@ from .logout import LogoutView
|
|||||||
from .ping import PingView
|
from .ping import PingView
|
||||||
from .vk_auth import VKAuthView
|
from .vk_auth import VKAuthView
|
||||||
from .yandex_auth import YandexAuthView
|
from .yandex_auth import YandexAuthView
|
||||||
|
from .is_staff import is_staff
|
||||||
|
24
web/views/is_staff.py
Normal file
24
web/views/is_staff.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from django.db.models import Q
|
||||||
|
from django.http import HttpResponse, JsonResponse
|
||||||
|
|
||||||
|
from Platform import settings
|
||||||
|
from web.models import CustomUser
|
||||||
|
|
||||||
|
|
||||||
|
def is_staff(request):
|
||||||
|
if request.headers.get("X-Security-Token") != settings.PLATFORM_SECURITY_TOKEN:
|
||||||
|
return HttpResponse('', status=403)
|
||||||
|
data = {}
|
||||||
|
vk_id = request.GET.get('vk_id')
|
||||||
|
if vk_id:
|
||||||
|
data['vk_id'] = vk_id
|
||||||
|
yandex_id = request.GET.get('yandex_id')
|
||||||
|
if yandex_id:
|
||||||
|
data['yandex_id'] = yandex_id
|
||||||
|
email = request.GET.get('email')
|
||||||
|
if email:
|
||||||
|
data['email'] = email
|
||||||
|
for key, value in data.items():
|
||||||
|
if len(CustomUser.objects.filter(**{key: value})) != 0:
|
||||||
|
return JsonResponse({'is_staff': True})
|
||||||
|
return JsonResponse({'is_staff': False})
|
Loading…
Reference in New Issue
Block a user