Skip to content

Commit

Permalink
Load google config conditionally (makes login broken if abstent)
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoxos committed Jun 25, 2024
1 parent 29de99a commit b877a20
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions webapi/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
logout_user,
UserMixin
)
import logging
log=logging.getLogger(__name__)
from oauthlib.oauth2 import WebApplicationClient
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'

Expand Down Expand Up @@ -56,11 +58,12 @@ def update_user_picture_url(user_id: str, val):
def update_user_name(user_id: str, val):
db.Users.update_one({'id': user_id}, { "$set": { 'name': val } })

persistentPath = "/var/lib/mupif/persistent"
googleConfigPath = persistentPath + "/google_auth_config.json"
login_config = {}
with open(googleConfigPath) as config_json:
login_config = json.load(config_json)
googleConfigPath = os.path.expanduser("~/persistent/google_auth_config.json")
if os.path.exists(googleConfigPath):
with open(googleConfigPath) as config_json:
login_config = json.load(config_json)
else: log.error("File '{googleConfigPath}' does not exist, login will be broken.")
GOOGLE_CLIENT_ID = login_config.get("GOOGLE_CLIENT_ID", None)
GOOGLE_CLIENT_SECRET = login_config.get("GOOGLE_CLIENT_SECRET", None)
GOOGLE_REDIRECT_URI = login_config.get("GOOGLE_REDIRECT_URI", None)
Expand Down

0 comments on commit b877a20

Please sign in to comment.