Reload when auth token mismatch is detected #6897

Merged
infinite-persistence merged 1 commit from ip/prevent.wallet.merge into master 2021-08-18 16:49:10 +02:00

View file

@ -3,9 +3,10 @@ import { Lbryio } from 'lbryinc';
import { SETTINGS, Lbry, doWalletEncrypt, doWalletDecrypt } from 'lbry-redux';
import { selectGetSyncIsPending, selectSetSyncIsPending, selectSyncIsLocked } from 'redux/selectors/sync';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { getSavedPassword } from 'util/saved-passwords';
import { getSavedPassword, getAuthToken } from 'util/saved-passwords';
import { doAnalyticsTagSync, doHandleSyncComplete } from 'redux/actions/app';
import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
let syncTimer = null;
const SYNC_INTERVAL = 1000 * 60 * 5; // 5 minutes
@ -148,6 +149,17 @@ export function doGetSync(passedPassword, callback) {
}
}
// @if TARGET='web'
const xAuth =
Lbry.getApiRequestHeaders() && Object.keys(Lbry.getApiRequestHeaders()).includes(X_LBRY_AUTH_TOKEN)
? Lbry.getApiRequestHeaders()[X_LBRY_AUTH_TOKEN]
: '';
if (xAuth && xAuth !== getAuthToken()) {
window.location.reload();
return;
}
// @endif
return (dispatch) => {
dispatch({
type: ACTIONS.GET_SYNC_STARTED,