Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
from server import * from server import *
import requests import requests
from mail import notify_admins
L2P_BASE = 'https://www3.elearning.rwth-aachen.de/_vti_bin/l2pservices/api.svc/v1/' 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/' OAUTH_BASE = 'https://oauth.campus.rwth-aachen.de/oauth2waitress/oauth2.svc/'
...@@ -66,7 +67,12 @@ def finish_oauth(): ...@@ -66,7 +67,12 @@ def finish_oauth():
session['l2p_courses'].append(course['uniqueid']) session['l2p_courses'].append(course['uniqueid'])
elif session['oauthscope'] == 'moodle': elif session['oauthscope'] == 'moodle':
session['moodle_courses'] = [] session['moodle_courses'] = []
for course in moodleget('getmyenrolledcourses', token['access_token'])['Data']: data = moodleget('getmyenrolledcourses', token['access_token'])
if data and data.get('Data'):
for course in data['Data']:
session['moodle_courses'].append(str(course['id'])) 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'] del session['oauthscope']
oauthget('token', refresh_token=token['refresh_token'], grant_type='invalidate') oauthget('token', refresh_token=token['refresh_token'], grant_type='invalidate')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment