add logic to trigger logout if user timed out on auth step

This commit is contained in:
Anton Georgiev 2017-05-09 16:04:30 -04:00
parent 10bd63e35d
commit e8fb481722

View File

@ -31,6 +31,12 @@ export function logoutRouteHandler(nextState, replace, callback) {
};
export function authenticatedRouteHandler(nextState, replace, callback) {
const credentialsSnapshot = {
meetingId: Auth.meetingID,
requesterUserId: Auth.userID,
requesterToken: Auth.token,
};
if (Auth.loggedIn) {
callback();
}
@ -40,7 +46,16 @@ export function authenticatedRouteHandler(nextState, replace, callback) {
Auth.authenticate()
.then(callback)
.catch(reason => {
logClient('error', { error: reason, method: 'authenticatedRouteHandler' });
logClient('error', { error: reason, method: 'authenticatedRouteHandler', credentialsSnapshot });
// make sure users who did not connect are not added to the meeting
// do **not** use the custom call - it relies on expired data
Meteor.call('userLogout', credentialsSnapshot, (error, result) => {
if (error) {
console.error('error');
}
});
replace({ pathname: `/error/${reason.error}` });
callback();
});