Fix for #1905 prevent invalid json data in gmail_token

This commit is contained in:
Ozzie Isaacs 2021-04-18 11:33:14 +02:00
parent c0a4addf30
commit 9cc14ac5c7
2 changed files with 5 additions and 2 deletions

View File

@ -20,6 +20,7 @@
from __future__ import division, print_function, unicode_literals from __future__ import division, print_function, unicode_literals
import os import os
import sys import sys
import json
from sqlalchemy import Column, String, Integer, SmallInteger, Boolean, BLOB, JSON from sqlalchemy import Column, String, Integer, SmallInteger, Boolean, BLOB, JSON
from sqlalchemy.exc import OperationalError from sqlalchemy.exc import OperationalError
@ -261,7 +262,6 @@ class _ConfigSQL(object):
""" """
new_value = dictionary.get(field, default) new_value = dictionary.get(field, default)
if new_value is None: if new_value is None:
# log.debug("_ConfigSQL set_from_dictionary field '%s' not found", field)
return False return False
if field not in self.__dict__: if field not in self.__dict__:
@ -278,7 +278,6 @@ class _ConfigSQL(object):
if current_value == new_value: if current_value == new_value:
return False return False
# log.debug("_ConfigSQL set_from_dictionary '%s' = %r (was %r)", field, new_value, current_value)
setattr(self, field, new_value) setattr(self, field, new_value)
return True return True
@ -383,6 +382,9 @@ def _migrate_table(session, orm_class):
log.debug(alter_table) log.debug(alter_table)
session.execute(alter_table) session.execute(alter_table)
changed = True changed = True
except json.decoder.JSONDecodeError as e:
log.error("Database corrupt column: {}".format(column_name))
log.debug(e)
if changed: if changed:
try: try:

View File

@ -53,6 +53,7 @@ def setup_gmail(token):
'expiry': creds.expiry.isoformat(), 'expiry': creds.expiry.isoformat(),
'email': user_info 'email': user_info
} }
return {}
def get_user_info(credentials): def get_user_info(credentials):
user_info_service = build(serviceName='oauth2', version='v2',credentials=credentials) user_info_service = build(serviceName='oauth2', version='v2',credentials=credentials)