diff --git a/bbb-learning-dashboard/src/App.js b/bbb-learning-dashboard/src/App.js index 52fe909a5c..4d3e54e52a 100644 --- a/bbb-learning-dashboard/src/App.js +++ b/bbb-learning-dashboard/src/App.js @@ -27,14 +27,27 @@ class App extends React.Component { const urlSearchParams = new URLSearchParams(window.location.search); const params = Object.fromEntries(urlSearchParams.entries()); if (typeof params.meeting === 'undefined') return; - if (typeof params.report === 'undefined') return; - fetch(`${params.meeting}/${params.report}/activity_report.json`) - .then((response) => response.json()) - .then((json) => { - this.setState({ activitiesJson: json }); - document.title = `Learning Dashboard - ${json.name}`; + let learningDashboardAccessToken = ''; + if (typeof params.report !== 'undefined') { + learningDashboardAccessToken = params.report; + } else { + const cookieName = `learningDashboardAccessToken-${params.meeting}`; + const cDecoded = decodeURIComponent(document.cookie); + const cArr = cDecoded.split('; '); + cArr.forEach((val) => { + if (val.indexOf(`${cookieName}=`) === 0) learningDashboardAccessToken = val.substring((`${cookieName}=`).length); }); + } + + if (learningDashboardAccessToken !== '') { + fetch(`${params.meeting}/${learningDashboardAccessToken}/activity_report.json`) + .then((response) => response.json()) + .then((json) => { + this.setState({ activitiesJson: json }); + document.title = `Learning Dashboard - ${json.name}`; + }); + } } render() { @@ -159,8 +172,13 @@ class App extends React.Component {