Reload when auth token mismatch is detected #6897
1 changed files with 13 additions and 1 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue