PLT-6492 Use new cookie to determine if user is logged in (#6317)
* Use new cookie to determine if user is logged in * Add temporary code for 3.9 to prevent forced re-login
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1838f6c25e
Коммит
fe95276ba8
@@ -457,7 +457,7 @@ export function clientLogout(redirectTo = '/') {
|
||||
ChannelStore.clear();
|
||||
stopPeriodicStatusUpdates();
|
||||
WebsocketActions.close();
|
||||
localStorage.removeItem('currentUserId');
|
||||
document.cookie = 'MMUSERID=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
||||
window.location.href = redirectTo;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,8 +51,6 @@ import {getTeamMembersByIds, getMyTeamMembers} from 'mattermost-redux/actions/te
|
||||
export function loadMe(callback) {
|
||||
loadMeRedux()(dispatch, getState).then(
|
||||
() => {
|
||||
localStorage.setItem('currentUserId', UserStore.getCurrentId());
|
||||
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
@@ -741,7 +739,6 @@ export function webLogin(loginId, password, token, success, error) {
|
||||
login(loginId, password, token)(dispatch, getState).then(
|
||||
(ok) => {
|
||||
if (ok && success) {
|
||||
localStorage.setItem('currentUserId', UserStore.getCurrentId());
|
||||
success();
|
||||
} else if (!ok && error) {
|
||||
const serverError = getState().requests.users.login.error;
|
||||
|
||||
@@ -13,7 +13,6 @@ import PDFJS from 'pdfjs-dist';
|
||||
import * as Websockets from 'actions/websocket_actions.jsx';
|
||||
import {loadMeAndConfig} from 'actions/user_actions.jsx';
|
||||
import ChannelStore from 'stores/channel_store.jsx';
|
||||
import UserStore from 'stores/user_store.jsx';
|
||||
import * as I18n from 'i18n/i18n.jsx';
|
||||
|
||||
// Import our styles
|
||||
@@ -61,9 +60,7 @@ function preRenderSetup(callwhendone) {
|
||||
|
||||
setUrl(window.location.origin);
|
||||
|
||||
const currentUserId = localStorage.getItem('currentUserId');
|
||||
|
||||
if (currentUserId) {
|
||||
if (document.cookie.indexOf('MMUSERID=') > -1) {
|
||||
loadMeAndConfig(() => d1.resolve());
|
||||
} else {
|
||||
getClientConfig()(store.dispatch, store.getState).then(
|
||||
@@ -85,7 +82,7 @@ function preRenderSetup(callwhendone) {
|
||||
() => {
|
||||
// Turn off to prevent getting stuck in a loop
|
||||
$(window).off('beforeunload');
|
||||
if (UserStore.getCurrentUser()) {
|
||||
if (document.cookie.indexOf('MMUSERID=') > -1) {
|
||||
viewChannel('', ChannelStore.getCurrentId() || '')(dispatch, getState);
|
||||
}
|
||||
Websockets.close();
|
||||
|
||||
@@ -77,6 +77,9 @@ export default function configureStore(initialState) {
|
||||
|
||||
persistor.purge();
|
||||
|
||||
document.cookie = 'MMUSERID=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
|
||||
window.location.href = '/';
|
||||
|
||||
store.dispatch(batchActions([
|
||||
{
|
||||
type: General.OFFLINE_STORE_RESET,
|
||||
@@ -84,9 +87,6 @@ export default function configureStore(initialState) {
|
||||
}
|
||||
]));
|
||||
|
||||
localStorage.removeItem('currentUserId');
|
||||
window.location.href = '/';
|
||||
|
||||
setTimeout(() => {
|
||||
purging = false;
|
||||
}, 500);
|
||||
|
||||
Ссылка в новой задаче
Block a user