Skip to content

Commit

Permalink
fix cors errors on attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalydosos committed Dec 26, 2024
1 parent 873dcec commit 5cbae41
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/components/TestToolMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ function TestToolMenu() {
/>
</TestToolRow>

{/* Sends an expired session to the FE and invalidates the session by the same time in the BE. Action is delayed for 15s */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.expiredSession')}>
<Button
small
text={translate('initialSettingsPage.troubleshoot.expireSessionWithDelay')}
onPress={() => Session.expireSessionWithDelay()}
/>
</TestToolRow>

<TestCrash />
</>
);
Expand Down
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,8 @@ const translations = {
debugMode: 'Debug mode',
invalidFile: 'Invalid file',
invalidFileDescription: 'The file you are trying to import is not valid. Please try again.',
expiredSession: 'Send expired session',
expireSessionWithDelay: 'Send with delay',
},
debugConsole: {
saveLog: 'Save log',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,8 @@ const translations = {
debugMode: 'Modo depuración',
invalidFile: 'Archivo inválido',
invalidFileDescription: 'El archivo que estás intentando importar no es válido. Por favor, inténtalo de nuevo.',
expiredSession: 'Enviar sesión caducada',
expireSessionWithDelay: 'Enviar con retraso',
},
debugConsole: {
saveLog: 'Guardar registro',
Expand Down
14 changes: 13 additions & 1 deletion src/libs/actions/Session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,18 @@ function invalidateCredentials() {

function invalidateAuthToken() {
NetworkStore.setAuthToken('pizza');
Onyx.merge(ONYXKEYS.SESSION, {authToken: 'pizza', encryptedAuthToken: 'pizza', creationDate: new Date().getTime() - CONST.SESSION_EXPIRATION_TIME_MS});
Onyx.merge(ONYXKEYS.SESSION, {authToken: 'pizza', encryptedAuthToken: 'pizza'});
}

/**
* Send an expired session to FE and invalidate the session in the BE. Action is delayed for 15s
*/
function expireSessionWithDelay() {
// expires the session after 15s
setTimeout(() => {
NetworkStore.setAuthToken('pizza');
Onyx.merge(ONYXKEYS.SESSION, {authToken: 'pizza', encryptedAuthToken: 'pizza', creationDate: new Date().getTime() - CONST.SESSION_EXPIRATION_TIME_MS});
}, 15000);
}

/**
Expand Down Expand Up @@ -1238,6 +1249,7 @@ export {
reauthenticatePusher,
invalidateCredentials,
invalidateAuthToken,
expireSessionWithDelay,
isAnonymousUser,
toggleTwoFactorAuth,
validateTwoFactorAuth,
Expand Down

0 comments on commit 5cbae41

Please sign in to comment.