diff --git a/api/serializers.py b/api/serializers.py index 69c1f78..d080c0c 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -159,7 +159,7 @@ class UserSerializer(serializers.ModelSerializer): extra_kwargs = {"password": {"write_only": True, "min_length": 5}} def create(self, validated_data): - return User.objects.create_user(**validated_data) + return User.objects.create_user(**validated_data) #type: ignore class AuthSerializer(serializers.Serializer): diff --git a/api/tasks.py b/api/tasks.py index a24085e..8ed3004 100644 --- a/api/tasks.py +++ b/api/tasks.py @@ -230,19 +230,11 @@ def verify_user_with_person_api_task(user_id: int): ): t_user.t_verified = True t_user.save() - send_sms( - t_user.t_mobile, - f"Dear {t_user.t_first_name} {t_user.t_last_name}, \n\nYour account has been successfully verified. \n\nYou can now manage your devices and make payments through our portal at https://portal.sarlink.net. \n\n - SAR Link", - ) return True else: t_user.t_verified = False t_user.save() - send_sms( - t_user.t_mobile, - f"Dear {t_user.t_first_name} {t_user.t_last_name}, \n\nYour account registration is being processed. \n\nWe will notify you once verification is complete. \n\n - SAR Link", - ) # send_clean_telegram_markdown(message=verification_failed_message) try: diff --git a/api/views.py b/api/views.py index 83161bb..9df2061 100644 --- a/api/views.py +++ b/api/views.py @@ -183,17 +183,34 @@ class VerifyOTPView(generics.GenericAPIView): acc_no=temp_user.t_acc_no, id_card=temp_user.t_id_card, dob=temp_user.t_dob, + verified=temp_user.t_verified, atoll=temp_user.t_atoll, island=temp_user.t_island, terms_accepted=temp_user.t_terms_accepted, policy_accepted=temp_user.t_policy_accepted, ) + if temp_user.t_verified: + send_sms( + t_user.t_mobile, + f"Dear {temp_user.t_first_name} {temp_user.t_last_name}, \n\nYour account has been successfully verified. \n\nYou can now manage your devices and make payments through our portal at https://portal.sarlink.net. \n\n - SAR Link", + ) + else: + send_sms( + t_user.t_mobile, + f"Dear {t_user.t_first_name} {t_user.t_last_name}, \n\nYour account registration is being processed. \n\nWe will notify you once verification is complete. \n\n - SAR Link", + ) + # You can now trigger registry verification as a signal or task temp_user.otp_verified = True temp_user.save() - return Response({"message": "User created successfully."}) + return Response( + { + "message": "User created successfully.", + "verified": temp_user.t_verified + } + ) class LoginView(KnoxLoginView):