bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/learning-dashboard/service.js
2024-06-14 11:35:53 -03:00

26 lines
872 B
JavaScript

import Auth from '/imports/ui/services/auth';
const setLearningDashboardCookie = (token) => {
if (token !== null) {
const lifetime = new Date();
lifetime.setTime(lifetime.getTime() + (3600000)); // 1h (extends 7d when open Dashboard)
document.cookie = `ld-${Auth.meetingID}=${token}; expires=${lifetime.toGMTString()}; path=/`;
return true;
}
return false;
};
const openLearningDashboardUrl = (lang, token) => {
const APP = window.meetingClientSettings.public.app;
if (token && setLearningDashboardCookie(token)) {
window.open(`${APP.learningDashboardBase}/?meeting=${Auth.meetingID}&lang=${lang}`, '_blank');
} else {
window.open(`${APP.learningDashboardBase}/?meeting=${Auth.meetingID}&sessionToken=${Auth.sessionToken}&lang=${lang}`, '_blank');
}
};
export default {
setLearningDashboardCookie,
openLearningDashboardUrl,
};