django-chelseru 1.0.7__tar.gz → 1.0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_chelseru-1.0.7/django_chelseru.egg-info → django_chelseru-1.0.9}/PKG-INFO +3 -3
- {django_chelseru-1.0.7 → django_chelseru-1.0.9/django_chelseru.egg-info}/PKG-INFO +3 -3
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/consumers.py +1 -1
- django_chelseru-1.0.9/drfchelseru/middlewares.py +111 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/services.py +49 -1
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/settings.py +73 -1
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/setup.py +3 -3
- django_chelseru-1.0.7/drfchelseru/middlewares.py +0 -80
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/LICENSE +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/MANIFEST.in +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/README.md +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/README_PA.md +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/django_chelseru.egg-info/SOURCES.txt +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/django_chelseru.egg-info/dependency_links.txt +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/django_chelseru.egg-info/requires.txt +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/django_chelseru.egg-info/top_level.txt +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/__init__.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/admin.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/apps.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0001_initial.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0002_otpcode_session_user.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0003_rename_mobile_otpcode_mobile_number.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0004_rename_message_message_sms.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0005_rename_message_sms_messagesms_chatroom_messagechat.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0006_alter_chatroom_user_1_alter_chatroom_user_2_and_more.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0007_chatroom_pinned_for_chatroom_status_chatroom_users_and_more.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0008_alter_chatroompermissions_user.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0009_alter_chatroom_status.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0010_chatroom_banneds_chatroom_descriptions_chatroom_name_and_more.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0011_alter_chatroom_user_1_alter_chatroom_user_2.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/__init__.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/models.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/routing.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/serializers.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/signals.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/tests.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/urls.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/validators.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/views.py +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/pyproject.toml +0 -0
- {django_chelseru-1.0.7 → django_chelseru-1.0.9}/setup.cfg +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-chelseru
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.9
|
|
4
4
|
Summary: Authentication system, online and real-time chat, SMS system for Iranian SMS services.
|
|
5
5
|
Home-page: https://pipdjango.chelseru.com
|
|
6
|
-
Author: Sobhan Bahman
|
|
6
|
+
Author: Sobhan Bahman Rashnu
|
|
7
7
|
Author-email: bahmanrashnu@gmail.com
|
|
8
8
|
Project-URL: Documentation, https://github.com/Chelseru/django-chelseru-lour/
|
|
9
9
|
Project-URL: Telegram Group, https://t.me/bahmanpy
|
|
10
10
|
Project-URL: Telegram Channel, https://t.me/ChelseruCom
|
|
11
|
-
Keywords: djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم
|
|
11
|
+
Keywords: djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu rashno lak lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Framework :: Django
|
|
14
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-chelseru
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.9
|
|
4
4
|
Summary: Authentication system, online and real-time chat, SMS system for Iranian SMS services.
|
|
5
5
|
Home-page: https://pipdjango.chelseru.com
|
|
6
|
-
Author: Sobhan Bahman
|
|
6
|
+
Author: Sobhan Bahman Rashnu
|
|
7
7
|
Author-email: bahmanrashnu@gmail.com
|
|
8
8
|
Project-URL: Documentation, https://github.com/Chelseru/django-chelseru-lour/
|
|
9
9
|
Project-URL: Telegram Group, https://t.me/bahmanpy
|
|
10
10
|
Project-URL: Telegram Channel, https://t.me/ChelseruCom
|
|
11
|
-
Keywords: djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم
|
|
11
|
+
Keywords: djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu rashno lak lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم
|
|
12
12
|
Classifier: Programming Language :: Python :: 3
|
|
13
13
|
Classifier: Framework :: Django
|
|
14
14
|
Classifier: License :: OSI Approved :: MIT License
|
|
@@ -10,7 +10,7 @@ User = get_user_model()
|
|
|
10
10
|
class ChatConsumer(AsyncWebsocketConsumer):
|
|
11
11
|
@sync_to_async
|
|
12
12
|
def is_user_in_chat_room(self, user, chat_room):
|
|
13
|
-
if chat_room.users.filter(
|
|
13
|
+
if chat_room.users.filter(id=user.id).exists():
|
|
14
14
|
return True
|
|
15
15
|
return user == chat_room.user_1 or user == chat_room.user_2
|
|
16
16
|
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
from django.utils.timezone import datetime
|
|
2
|
+
from .models import Session
|
|
3
|
+
import user_agents
|
|
4
|
+
|
|
5
|
+
from urllib.parse import parse_qs
|
|
6
|
+
from channels.middleware import BaseMiddleware
|
|
7
|
+
from django.contrib.auth.models import AnonymousUser
|
|
8
|
+
from rest_framework_simplejwt.tokens import AccessToken
|
|
9
|
+
from django.contrib.auth import get_user_model
|
|
10
|
+
from asgiref.sync import sync_to_async
|
|
11
|
+
|
|
12
|
+
from .settings import auth_init_check, AUTH_SERVICE_DJSESSION, AUTH_SERVICE_DJSESSION
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class TakeUserSessionMiddlaware:
|
|
16
|
+
def __init__(self, get_response):
|
|
17
|
+
self.get_response = get_response
|
|
18
|
+
|
|
19
|
+
def __call__(self, request):
|
|
20
|
+
response = self.get_response(request)
|
|
21
|
+
|
|
22
|
+
if request.user.is_authenticated:
|
|
23
|
+
user_agent = request.META.get('HTTP_USER_AGENT', '')
|
|
24
|
+
ip = self.get_client_ip(request)
|
|
25
|
+
|
|
26
|
+
icheck = auth_init_check()
|
|
27
|
+
session = None
|
|
28
|
+
|
|
29
|
+
if icheck['AUTH_SERVICE'] == AUTH_SERVICE_DJSESSION:
|
|
30
|
+
if not request.session.session_key:
|
|
31
|
+
request.session.create()
|
|
32
|
+
session_key = request.session.session_key
|
|
33
|
+
|
|
34
|
+
try:
|
|
35
|
+
# get session
|
|
36
|
+
session = Session.objects.get(session_key=session_key)
|
|
37
|
+
|
|
38
|
+
except Session.DoesNotExist:
|
|
39
|
+
# create
|
|
40
|
+
session = Session.objects.create(
|
|
41
|
+
user = request.user,
|
|
42
|
+
session_key = session_key,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
elif icheck['AUTH_SERVICE'] == AUTH_SERVICE_JWT:
|
|
46
|
+
try:
|
|
47
|
+
session = Session.objects.get(user=request.user)
|
|
48
|
+
except Session.DoesNotExist:
|
|
49
|
+
pass
|
|
50
|
+
|
|
51
|
+
if session:
|
|
52
|
+
session.user_agent = user_agent
|
|
53
|
+
session.ip_address = ip_address
|
|
54
|
+
session.device = user_agents.parse(user_agent).device.family
|
|
55
|
+
session.browser = user_agents.parse(user_agent).browser.family
|
|
56
|
+
session.last_seen = datetime.now()
|
|
57
|
+
|
|
58
|
+
session.save()
|
|
59
|
+
|
|
60
|
+
# session, created = Session.objects.get_or_create(
|
|
61
|
+
# user = request.user,
|
|
62
|
+
# session_key = session_key,
|
|
63
|
+
# defaults = {
|
|
64
|
+
# 'user_agent': user_agent,
|
|
65
|
+
# 'ip_address': ip,
|
|
66
|
+
# 'device': user_agents.parse(user_agent).device.family,
|
|
67
|
+
# 'browser': user_agents.parse(user_agent).browser.family,
|
|
68
|
+
# }
|
|
69
|
+
# )
|
|
70
|
+
|
|
71
|
+
# session.user_agent = user_agent
|
|
72
|
+
# session.ip_address = ip
|
|
73
|
+
# session.last_seen = datetime.now()
|
|
74
|
+
# session.save()
|
|
75
|
+
|
|
76
|
+
return response
|
|
77
|
+
|
|
78
|
+
def get_client_ip(self, request):
|
|
79
|
+
x_forwarded_for = request.META.get('X_FORWARDED_FOR')
|
|
80
|
+
if x_forwarded_for:
|
|
81
|
+
return x_forwarded_for.split(',')[0]
|
|
82
|
+
return request.META.get('REMOTE_ADDR')
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
User = get_user_model()
|
|
87
|
+
|
|
88
|
+
@sync_to_async
|
|
89
|
+
def get_user(validated_token):
|
|
90
|
+
try:
|
|
91
|
+
user_id = validated_token["user_id"]
|
|
92
|
+
return User.objects.get(id=user_id)
|
|
93
|
+
except User.DoesNotExist:
|
|
94
|
+
return AnonymousUser()
|
|
95
|
+
|
|
96
|
+
class JWTAuthMiddleware(BaseMiddleware):
|
|
97
|
+
async def __call__(self, scope, receive, send):
|
|
98
|
+
query_string = scope.get("query_string", b"").decode()
|
|
99
|
+
query_params = parse_qs(query_string)
|
|
100
|
+
token = query_params.get("token")
|
|
101
|
+
|
|
102
|
+
if token:
|
|
103
|
+
try:
|
|
104
|
+
access_token = AccessToken(token[0])
|
|
105
|
+
scope["user"] = await get_user(access_token)
|
|
106
|
+
except Exception as e:
|
|
107
|
+
scope["user"] = AnonymousUser()
|
|
108
|
+
else:
|
|
109
|
+
scope["user"] = AnonymousUser()
|
|
110
|
+
|
|
111
|
+
return await super().__call__(scope, receive, send)
|
|
@@ -5,7 +5,7 @@ from zeep import Client
|
|
|
5
5
|
from rest_framework.status import HTTP_200_OK, HTTP_204_NO_CONTENT, HTTP_500_INTERNAL_SERVER_ERROR, HTTP_502_BAD_GATEWAY, HTTP_401_UNAUTHORIZED, HTTP_400_BAD_REQUEST
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
from .settings import sms_init_check
|
|
8
|
+
from .settings import sms_init_check, bank_init_check
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class ParsianWebcoIr:
|
|
@@ -237,3 +237,51 @@ def send_message(mobile_number, message_text, data=None, template_id=None):
|
|
|
237
237
|
return False, {'details': 'Invalid response structure.', 'error': str(e)}
|
|
238
238
|
|
|
239
239
|
return response_bool, {'data': response_data, 'obj_status': obj_status, 'status': response_status_code}
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class ZarinpalCom:
|
|
245
|
+
"""
|
|
246
|
+
merchant_id
|
|
247
|
+
currency
|
|
248
|
+
"""
|
|
249
|
+
def __init__(self, merchant_id):
|
|
250
|
+
self.merchant_id = merchant_id
|
|
251
|
+
|
|
252
|
+
def create_payment(self, amount, callback_url, description, order_id=None, mobile=None, email=None, currency=None, **metadata):
|
|
253
|
+
'''
|
|
254
|
+
curl -X POST \
|
|
255
|
+
https://payment.zarinpal.com/pg/v4/payment/request.json \
|
|
256
|
+
-H 'accept: application/json' \
|
|
257
|
+
-H 'content-type: application/json' \
|
|
258
|
+
-d '{
|
|
259
|
+
"merchant_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
260
|
+
"amount": 1000,
|
|
261
|
+
"callback_url": "http://your-site.com/verify",
|
|
262
|
+
"description": "Transaction description.",
|
|
263
|
+
"metadata": {"mobile": "09121234567","email": "info.test@gmail.com"}
|
|
264
|
+
}
|
|
265
|
+
___
|
|
266
|
+
|
|
267
|
+
{
|
|
268
|
+
"data": {
|
|
269
|
+
"code": 100,
|
|
270
|
+
"message": "Success",
|
|
271
|
+
"authority": "A0000000000000000000000000000wwOGYpd",
|
|
272
|
+
"fee_type": "Merchant",
|
|
273
|
+
"fee": 100
|
|
274
|
+
},
|
|
275
|
+
"errors": []
|
|
276
|
+
}
|
|
277
|
+
'''
|
|
278
|
+
try:
|
|
279
|
+
icheck = bank_init_check()
|
|
280
|
+
if not icheck:
|
|
281
|
+
raise ImproperlyConfigured('Configure Bank in DJANGO_CHELSERU.')
|
|
282
|
+
|
|
283
|
+
except ImproperlyConfigured as e:
|
|
284
|
+
raise
|
|
285
|
+
except:
|
|
286
|
+
pass
|
|
287
|
+
pass
|
|
@@ -29,6 +29,14 @@ DJANGO_CHELSERU = {
|
|
|
29
29
|
'T7': 7,
|
|
30
30
|
'T8': 8,
|
|
31
31
|
'T9': 9,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
'BANK': {
|
|
35
|
+
'GATEWAY': 'ZARINPAL_COM',
|
|
36
|
+
'SETTINGS': {
|
|
37
|
+
'MERCHANT_ID': '',
|
|
38
|
+
'CALLBACK_URL': '',
|
|
39
|
+
'CURRENCY': 'IRT', # IRR, IRT
|
|
32
40
|
}
|
|
33
41
|
}
|
|
34
42
|
}
|
|
@@ -39,9 +47,15 @@ from django.core.exceptions import ImproperlyConfigured
|
|
|
39
47
|
|
|
40
48
|
SERVICE_NAME = 'DJANGO_CHELSERU'
|
|
41
49
|
|
|
50
|
+
AUTH_SERVICE_JWT = 'rest_framework_simplejwt'
|
|
51
|
+
AUTH_SERVICE_DJSESSION = 'django_session'
|
|
52
|
+
|
|
42
53
|
AUTH_METHOD = [(0, 'OTP'), (1, 'PASSWD')]
|
|
43
|
-
AUTH_SERVICES = [(0,
|
|
54
|
+
AUTH_SERVICES = [(0, AUTH_SERVICE_JWT)]
|
|
44
55
|
SMS_SERVICES = [(0, 'PARSIAN_WEBCO_IR'),(1, 'MELI_PAYAMAK_COM') ,(2, 'KAVENEGAR_COM')]
|
|
56
|
+
GATEWAYS = ((0, 'ZARINPAL_COM'),)
|
|
57
|
+
CURRENCIES = ((0, 'IRT'), (1, 'IRR'))
|
|
58
|
+
|
|
45
59
|
|
|
46
60
|
def auth_init_check():
|
|
47
61
|
try:
|
|
@@ -185,3 +199,61 @@ def sms_init_check():
|
|
|
185
199
|
return False
|
|
186
200
|
|
|
187
201
|
|
|
202
|
+
def bank_init_check():
|
|
203
|
+
gateway = None
|
|
204
|
+
options = {
|
|
205
|
+
'currency': 'IRT',
|
|
206
|
+
}
|
|
207
|
+
try:
|
|
208
|
+
if not hasattr(settings, SERVICE_NAME):
|
|
209
|
+
raise ImproperlyConfigured(f'{SERVICE_NAME} must be defined in settings.py.')
|
|
210
|
+
|
|
211
|
+
else:
|
|
212
|
+
bank = getattr(settings, SERVICE_NAME).get('BANK')
|
|
213
|
+
if not bank:
|
|
214
|
+
raise ImproperlyConfigured(f'BANK key must be defined in {SERVICE_NAME}')
|
|
215
|
+
else:
|
|
216
|
+
gateway = bank.get('GATEWAY')
|
|
217
|
+
if gateway not in list(map(lambda x: x[1], GATEWAYS)):
|
|
218
|
+
raise ImproperlyConfigured(f'GATEWAY must be choice between {list(map(lambda x:x[1], GATEWAYS))}.')
|
|
219
|
+
|
|
220
|
+
else:
|
|
221
|
+
_settings = bank.get('SETTINGS')
|
|
222
|
+
if not _settings:
|
|
223
|
+
raise ImproperlyConfigured(f'SETTINGS key must be defined in BANK')
|
|
224
|
+
else:
|
|
225
|
+
_merchant_id = _settings.get('MERCHANT_ID')
|
|
226
|
+
_callback_url = _settings.get('CALLBACK_URL')
|
|
227
|
+
_currency = _settings.get('CORRENCY')
|
|
228
|
+
|
|
229
|
+
if not _merchant_id:
|
|
230
|
+
raise ImproperlyConfigured(f'MERCHANT_ID key must be defined in SETTINGS.')
|
|
231
|
+
if not _callback_url:
|
|
232
|
+
raise ImproperlyConfigured(f'CALLBACK_URL key must be defined in SETTINGS.')
|
|
233
|
+
|
|
234
|
+
options['merchant_id'] = _merchant_id
|
|
235
|
+
options['callback_url'] = _callback_url
|
|
236
|
+
|
|
237
|
+
if _currency:
|
|
238
|
+
options['currency'] = _currency
|
|
239
|
+
|
|
240
|
+
return {'gateway': gateway, 'settings': options}
|
|
241
|
+
except ImproperlyConfigured as e:
|
|
242
|
+
print(f"Configuration Error: {e}")
|
|
243
|
+
raise
|
|
244
|
+
except:
|
|
245
|
+
pass
|
|
246
|
+
|
|
247
|
+
return False
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
'''
|
|
251
|
+
'BANK': {
|
|
252
|
+
'GATEWAY': 'ZARINPAL_COM',
|
|
253
|
+
'SETTINGS': {
|
|
254
|
+
'MERCHANT_ID': '',
|
|
255
|
+
'CALLBACK_URL': '',
|
|
256
|
+
'CURRENCY': 'IRT', # IRR, IRT
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
'''
|
|
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
|
|
|
3
3
|
|
|
4
4
|
setup(
|
|
5
5
|
name='django-chelseru',
|
|
6
|
-
version='1.0.
|
|
6
|
+
version='1.0.9',
|
|
7
7
|
packages=find_packages(),
|
|
8
8
|
include_package_data=True,
|
|
9
9
|
install_requires=[
|
|
@@ -16,7 +16,7 @@ setup(
|
|
|
16
16
|
'zeep==4.3.1',
|
|
17
17
|
'user-agents==2.2.0'
|
|
18
18
|
],
|
|
19
|
-
author='Sobhan Bahman
|
|
19
|
+
author='Sobhan Bahman Rashnu',
|
|
20
20
|
author_email='bahmanrashnu@gmail.com',
|
|
21
21
|
description='Authentication system, online and real-time chat, SMS system for Iranian SMS services.',
|
|
22
22
|
long_description=open('README.md').read(),
|
|
@@ -34,5 +34,5 @@ setup(
|
|
|
34
34
|
'Operating System :: OS Independent',
|
|
35
35
|
],
|
|
36
36
|
python_requires='>=3.11',
|
|
37
|
-
keywords="djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم",
|
|
37
|
+
keywords="djangochelseruchat djangochat drfchat online-chat online real-time chat iran chelseru lor lur bahman rashnu rashno lak lour sms djangoauth auth ywt otpauth otp authentication djangootp djangoiransms iransms djangosms djangokavenegar djangomelipayamak sobhan چت سبحان بهمن رشنو چلسرو جنگو پایتون لر لور آنلاین ریل تایم",
|
|
38
38
|
)
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
from django.utils.timezone import datetime
|
|
2
|
-
from .models import Session
|
|
3
|
-
import user_agents
|
|
4
|
-
|
|
5
|
-
from urllib.parse import parse_qs
|
|
6
|
-
from channels.middleware import BaseMiddleware
|
|
7
|
-
from django.contrib.auth.models import AnonymousUser
|
|
8
|
-
from rest_framework_simplejwt.tokens import AccessToken
|
|
9
|
-
from django.contrib.auth import get_user_model
|
|
10
|
-
from asgiref.sync import sync_to_async
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class TakeUserSessionMiddlaware:
|
|
14
|
-
def __init__(self, get_response):
|
|
15
|
-
self.get_response = get_response
|
|
16
|
-
|
|
17
|
-
def __call__(self, request):
|
|
18
|
-
response = self.get_response(request)
|
|
19
|
-
|
|
20
|
-
if request.user.is_authenticated:
|
|
21
|
-
user_agent = request.META.get('HTTP_USER_AGENT', '')
|
|
22
|
-
ip = self.get_client_ip(request)
|
|
23
|
-
|
|
24
|
-
if not request.session.session_key:
|
|
25
|
-
request.session.create()
|
|
26
|
-
|
|
27
|
-
session_key = request.session.session_key
|
|
28
|
-
|
|
29
|
-
session, created = Session.objects.get_or_create(
|
|
30
|
-
user = request.user,
|
|
31
|
-
session_key = session_key,
|
|
32
|
-
defaults = {
|
|
33
|
-
'user_agent': user_agent,
|
|
34
|
-
'ip_address': ip,
|
|
35
|
-
'device': user_agents.parse(user_agent).device.family,
|
|
36
|
-
'browser': user_agents.parse(user_agent).browser.family,
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
session.user_agent = user_agent
|
|
41
|
-
session.ip_address = ip
|
|
42
|
-
session.last_seen = datetime.now()
|
|
43
|
-
session.save()
|
|
44
|
-
|
|
45
|
-
return response
|
|
46
|
-
|
|
47
|
-
def get_client_ip(self, request):
|
|
48
|
-
x_forwarded_for = request.META.get('X_FORWARDED_FOR')
|
|
49
|
-
if x_forwarded_for:
|
|
50
|
-
return x_forwarded_for.split(',')[0]
|
|
51
|
-
return request.META.get('REMOTE_ADDR')
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
User = get_user_model()
|
|
56
|
-
|
|
57
|
-
@sync_to_async
|
|
58
|
-
def get_user(validated_token):
|
|
59
|
-
try:
|
|
60
|
-
user_id = validated_token["user_id"]
|
|
61
|
-
return User.objects.get(id=user_id)
|
|
62
|
-
except User.DoesNotExist:
|
|
63
|
-
return AnonymousUser()
|
|
64
|
-
|
|
65
|
-
class JWTAuthMiddleware(BaseMiddleware):
|
|
66
|
-
async def __call__(self, scope, receive, send):
|
|
67
|
-
query_string = scope.get("query_string", b"").decode()
|
|
68
|
-
query_params = parse_qs(query_string)
|
|
69
|
-
token = query_params.get("token")
|
|
70
|
-
|
|
71
|
-
if token:
|
|
72
|
-
try:
|
|
73
|
-
access_token = AccessToken(token[0])
|
|
74
|
-
scope["user"] = await get_user(access_token)
|
|
75
|
-
except Exception as e:
|
|
76
|
-
scope["user"] = AnonymousUser()
|
|
77
|
-
else:
|
|
78
|
-
scope["user"] = AnonymousUser()
|
|
79
|
-
|
|
80
|
-
return await super().__call__(scope, receive, send)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-1.0.7 → django_chelseru-1.0.9}/django_chelseru.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0002_otpcode_session_user.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{django_chelseru-1.0.7 → django_chelseru-1.0.9}/drfchelseru/migrations/0009_alter_chatroom_status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|