From cce57bca729aef367da845d2ed64816d8a515d0a Mon Sep 17 00:00:00 2001 From: Swapnil Date: Tue, 30 Jan 2024 20:54:03 +0530 Subject: [PATCH] db-service: fix required fields checking --- database/main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/database/main.py b/database/main.py index d55ee95..a694ec4 100644 --- a/database/main.py +++ b/database/main.py @@ -34,8 +34,11 @@ def create_token(): refresh_token = data.get('refresh_token') expiration_seconds = data.get('expiration_seconds') - if not email or access_token or not refresh_token or not expiration_seconds: - return 'Missing required fields', 400 + required_fields = ['email', 'access_token', 'refresh_token', 'expiration_seconds'] + missing_fields = [field for field in required_fields if not data.get(field)] + + if missing_fields: + return jsonify({'error': f'Missing required fields: {", ".join(missing_fields)}'}), 400 # unique email when active is true existing_token = Token.query.filter_by(email=email, active=True).first()