Unverified Commit f42bf61d authored by Roman Sebastian Karwacik's avatar Roman Sebastian Karwacik
Browse files

If moodleauth fails, send request to admins, no personal data shared as \`Data\` has to be empty

fix

fix
parent bf38fa18
from server import *
import requests
from mail import notify_admins
L2P_BASE = 'https://www3.elearning.rwth-aachen.de/_vti_bin/l2pservices/api.svc/v1/'
OAUTH_BASE = 'https://oauth.campus.rwth-aachen.de/oauth2waitress/oauth2.svc/'
......@@ -66,7 +67,12 @@ def finish_oauth():
session['l2p_courses'].append(course['uniqueid'])
elif session['oauthscope'] == 'moodle':
session['moodle_courses'] = []
for course in moodleget('getmyenrolledcourses', token['access_token'])['Data']:
session['moodle_courses'].append(str(course['id']))
data = moodleget('getmyenrolledcourses', token['access_token'])
if data and data.get('Data'):
for course in data['Data']:
session['moodle_courses'].append(str(course['id']))
else:
notify_admins('endpoint_exception', traceback=f"finish_oauth failed while getting moodle courses, data={str(data)}")
raise
del session['oauthscope']
oauthget('token', refresh_token=token['refresh_token'], grant_type='invalidate')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment