diff --git a/config/conf/celery.py b/config/conf/celery.py index 59b4482..990d399 100644 --- a/config/conf/celery.py +++ b/config/conf/celery.py @@ -5,3 +5,5 @@ CELERY_BROKER_URL = 'redis://redis:6379/0' CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_TIMEZONE = settings.TIME_ZONE + +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') diff --git a/core/apps/accounts/cache/user.py b/core/apps/accounts/cache/user.py index 9c0e83e..015199e 100644 --- a/core/apps/accounts/cache/user.py +++ b/core/apps/accounts/cache/user.py @@ -8,12 +8,11 @@ r = redis.StrictRedis.from_url(env.str('REDIS_URL')) def cache_user_credentials(phone_number, password, time): - hashed_password = make_password(password) key = f"user_credentials:{phone_number}" r.hmset(key, { "phone": phone_number, - "password": hashed_password + "password": password }) r.expire(key, time) diff --git a/core/apps/accounts/serializers/auth.py b/core/apps/accounts/serializers/auth.py index 95d2064..4b20947 100644 --- a/core/apps/accounts/serializers/auth.py +++ b/core/apps/accounts/serializers/auth.py @@ -19,9 +19,8 @@ class LoginSerializer(serializers.Serializer): user = User.objects.get(phone=data.get('phone')) except User.DoesNotExist: raise serializers.ValidationError({'detail': 'User not found'}) - else: - if not user.check_password(data.get('password')): - raise serializers.ValidationError({'detail': 'User not found'}) + if not user.check_password(data.get('password')): + raise serializers.ValidationError({'detail': 'User not found, password'}) data['user'] = user return data diff --git a/core/apps/accounts/views/auth.py b/core/apps/accounts/views/auth.py index d6500f7..d54b47f 100644 --- a/core/apps/accounts/views/auth.py +++ b/core/apps/accounts/views/auth.py @@ -56,7 +56,9 @@ class ConfirUserApiView(generics.GenericAPIView): data = get_user_creadentials(phone) if not data: return error_message("Not found", 404) - user = User.objects.create_user(phone=data['phone'], password=data['password']) + user = User.objects.create_user(phone=data['phone']) + user.set_password(data['password']) + user.save() confirmation.is_verify = True confirmation.save() token = RefreshToken.for_user(user)