2021-07-16 08:23:16 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
|
2024-06-14 21:30:48 +08:00
|
|
|
const setLearningDashboardCookie = (token) => {
|
|
|
|
if (token !== null) {
|
2021-12-15 21:35:14 +08:00
|
|
|
const lifetime = new Date();
|
|
|
|
lifetime.setTime(lifetime.getTime() + (3600000)); // 1h (extends 7d when open Dashboard)
|
2024-06-14 21:30:48 +08:00
|
|
|
document.cookie = `ld-${Auth.meetingID}=${token}; expires=${lifetime.toGMTString()}; path=/`;
|
2021-10-15 01:00:25 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
};
|
2021-07-16 08:23:16 +08:00
|
|
|
|
2024-06-14 21:30:48 +08:00
|
|
|
const openLearningDashboardUrl = (lang, token) => {
|
2024-03-07 01:28:18 +08:00
|
|
|
const APP = window.meetingClientSettings.public.app;
|
2024-06-14 21:30:48 +08:00
|
|
|
if (token && setLearningDashboardCookie(token)) {
|
2021-11-19 05:52:20 +08:00
|
|
|
window.open(`${APP.learningDashboardBase}/?meeting=${Auth.meetingID}&lang=${lang}`, '_blank');
|
2021-10-15 01:00:25 +08:00
|
|
|
} else {
|
2021-11-19 05:52:20 +08:00
|
|
|
window.open(`${APP.learningDashboardBase}/?meeting=${Auth.meetingID}&sessionToken=${Auth.sessionToken}&lang=${lang}`, '_blank');
|
2021-10-15 01:00:25 +08:00
|
|
|
}
|
2021-07-16 08:23:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
2021-10-15 01:00:25 +08:00
|
|
|
setLearningDashboardCookie,
|
2021-08-25 22:38:35 +08:00
|
|
|
openLearningDashboardUrl,
|
2021-07-16 08:23:16 +08:00
|
|
|
};
|