From 1fc12dd8ba2238eba7d154eee55e1381e7415372 Mon Sep 17 00:00:00 2001 From: =Corey Hulen Date: Tue, 20 Oct 2015 14:49:42 -0700 Subject: Multi-session login --- web/react/utils/client.jsx | 16 ++++++++-------- web/react/utils/utils.jsx | 10 +++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'web/react/utils') diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx index fab0640fb..ee1f9ad27 100644 --- a/web/react/utils/client.jsx +++ b/web/react/utils/client.jsx @@ -48,14 +48,14 @@ function handleError(methodName, xhr, status, err) { track('api', 'api_weberror', methodName, 'message', msg); - // if (xhr.status === 401) { - // if (window.location.href.indexOf('/channels') === 0) { - // window.location.pathname = '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search); - // } else { - // var teamURL = window.location.href.split('/channels')[0]; - // window.location.href = teamURL + '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search); - // } - // } + if (xhr.status === 401) { + if (window.location.href.indexOf('/channels') === 0) { + window.location.pathname = '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search); + } else { + var teamURL = window.location.href.split('/channels')[0]; + window.location.href = teamURL + '/login?redirect=' + encodeURIComponent(window.location.pathname + window.location.search); + } + } return e; } diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index 38ac68d58..f17a55142 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -872,7 +872,7 @@ export function getFileUrl(filename) { if (url.indexOf('/api/v1/files/get') !== -1) { url = filename.split('/api/v1/files/get')[1]; } - url = getWindowLocationOrigin() + '/api/v1/files/get' + url; + url = getWindowLocationOrigin() + '/api/v1/files/get' + url + '?' + getSessionIndex(); return url; } @@ -883,6 +883,14 @@ export function getFileName(path) { return split[split.length - 1]; } +export function getSessionIndex() { + if (global.window.mm_session_token_index >= 0) { + return 'session_token_index=' + global.window.mm_session_token_index; + } + + return ''; +} + // Generates a RFC-4122 version 4 compliant globally unique identifier. export function generateId() { // implementation taken from http://stackoverflow.com/a/2117523 -- cgit v1.2.3-1-g7c22