before change Ticket Desc to TextArea
This commit is contained in:
1 parent
f7dbd02a6c
commit
ef18434b86
55 files changed
+1026
-59
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.2.1 on 2024-02-10 09:59
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jwt_auth', '0081_alter_cuserroleloginopt_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='cuserroleloginopt',
|
||||
name='uuid',
|
||||
field=models.UUIDField(default=uuid.UUID('6537ef3d-8ef9-486d-a1b6-7892e021dc19'), unique=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.2.1 on 2024-02-10 11:06
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jwt_auth', '0082_alter_cuserroleloginopt_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='cuserroleloginopt',
|
||||
name='uuid',
|
||||
field=models.UUIDField(default=uuid.UUID('745db968-c736-42cd-ad3d-4de41e8e5b98'), unique=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.2.1 on 2024-02-18 09:44
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jwt_auth', '0083_alter_cuserroleloginopt_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='cuserroleloginopt',
|
||||
name='uuid',
|
||||
field=models.UUIDField(default=uuid.UUID('96211808-5203-451b-a6ce-eee394e02afc'), unique=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.2.1 on 2024-02-27 09:59
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jwt_auth', '0084_alter_cuserroleloginopt_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='cuserroleloginopt',
|
||||
name='uuid',
|
||||
field=models.UUIDField(default=uuid.UUID('561d07a5-fff4-436f-bab3-4e3b16e05fba'), unique=True),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 4.2.1 on 2024-04-16 06:28
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('jwt_auth', '0085_alter_cuserroleloginopt_uuid'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='cuserroleloginopt',
|
||||
name='uuid',
|
||||
field=models.UUIDField(default=uuid.UUID('b5346fad-8d28-482d-8ed9-2807850b6a4d'), unique=True),
|
||||
),
|
||||
]
|
||||
@@ -5,14 +5,16 @@ from apps.jwt_auth.models import CUserRoleLoginOpt
|
||||
from apps.cuser.models import CuserRole as CuserRoleModel, SmsOpt as SmsOptModel
|
||||
from django.utils import timezone
|
||||
from rest_framework import exceptions
|
||||
CUser = get_user_model()
|
||||
import requests
|
||||
from datetime import timedelta
|
||||
|
||||
CUser = get_user_model()
|
||||
|
||||
def login_by_username(username: str, password: str) -> CUserRoleLoginOpt:
|
||||
try:
|
||||
print(username)
|
||||
user = CUser.objects.get(username=username)
|
||||
print(user)
|
||||
|
||||
if user and user.check_password(password):
|
||||
|
||||
cuser_roles = CuserRoleModel.objects.filter(cuser=user)
|
||||
@@ -52,21 +54,35 @@ def login_by_mobile(mobile: int):
|
||||
|
||||
random_number = random.randint(100000, 999999)
|
||||
|
||||
|
||||
try:
|
||||
SmsOptModel.objects.filter(mobile=mobile).delete()
|
||||
except Exception as exp:
|
||||
pass
|
||||
|
||||
opt_code = SmsOptModel(mobile=mobile, opt=123456)
|
||||
expire_time = timezone.now() + timedelta(minutes=3)
|
||||
opt_code = SmsOptModel(mobile=mobile, opt=random_number, expire=expire_time)
|
||||
opt_code.save()
|
||||
|
||||
sms_text = f' کد ورود شما: {random_number}'
|
||||
|
||||
payload = {
|
||||
'USERNAME': 'vsms7937',
|
||||
'PASSWORD': '335577775533',
|
||||
'FROM': '30005367',
|
||||
'TO': int(mobile),
|
||||
'TEXT': f'{sms_text}'
|
||||
}
|
||||
r = requests.get('http://www.0098sms.com/sendsmslink.aspx', params=payload)
|
||||
|
||||
except Exception as exp:
|
||||
raise exceptions.ValidationError({'error': "mobile not found"})
|
||||
|
||||
|
||||
def verify_mobile_and_get_token(mobile: int, opt: int) -> CUserRoleLoginOpt:
|
||||
try:
|
||||
opt_obj = SmsOptModel.objects.filter(mobile=mobile, opt=opt)[0]
|
||||
time_now = timezone.now()
|
||||
opt_obj = SmsOptModel.objects.filter(mobile=mobile, opt=opt, expire__gte=time_now)[0]
|
||||
|
||||
if opt_obj:
|
||||
cuser_roles = CuserRoleModel.objects.filter(cuser__mobile=mobile, is_active=True)
|
||||
@@ -87,4 +103,8 @@ def verify_mobile_and_get_token(mobile: int, opt: int) -> CUserRoleLoginOpt:
|
||||
SmsOptModel.objects.filter(mobile=mobile).delete()
|
||||
return login_opts
|
||||
except Exception as exp:
|
||||
try:
|
||||
SmsOptModel.objects.filter(mobile=mobile).delete()
|
||||
except Exception as exp:
|
||||
pass
|
||||
raise exceptions.ValidationError({'error': "cannot verify this mobile and opt code:"+str(exp)})
|
||||
Reference in new issue
Block a user