db-service: fix required fields checking
This commit is contained in:
parent
3ec293e1fa
commit
cce57bca72
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user