Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return data from Reauthentication middleware when shouldRetry: false #9961

Merged
merged 2 commits into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/TestToolMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as Network from '../libs/actions/Network';
import * as Session from '../libs/actions/Session';
import ONYXKEYS from '../ONYXKEYS';
import Button from './Button';
import * as NetworkStore from '../libs/Network/NetworkStore';
import TestToolRow from './TestToolRow';
import networkPropTypes from './networkPropTypes';
import compose from '../libs/compose';
Expand Down Expand Up @@ -60,7 +59,7 @@ const TestToolMenu = props => (
<Button
small
text="Invalidate"
onPress={() => NetworkStore.setAuthToken('pizza')}
onPress={() => Session.invalidateAuthToken()}
/>
</TestToolRow>

Expand Down
2 changes: 1 addition & 1 deletion src/libs/Middleware/Reauthentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function Reauthentication(response, request, isFromSequentialQueue) {
if (request.resolve) {
request.resolve(data);
}
return;
return data;
}

// We are already authenticating
Expand Down
6 changes: 6 additions & 0 deletions src/libs/actions/Session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ function invalidateCredentials() {
Onyx.merge(ONYXKEYS.CREDENTIALS, {autoGeneratedLogin: '', autoGeneratedPassword: ''});
}

function invalidateAuthToken() {
NetworkStore.setAuthToken('pizza');
Onyx.merge(ONYXKEYS.SESSION, {authToken: 'pizza'});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pizza? lol, did you mean to clear it here instead or actually leave it as pizza?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol seems like we were already doing that in TestToolsMenu haha. I like it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍕 if we set it as null the user would be logged out or other weird things. So "bad authToken" vs. "no authToken" is what we want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, can that be added as a comment so that its not easily forgotten for the next person updating this block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyway, im not going to block since adding a comment is a NAB. Going to approve and merge this since its the only thing blocking deploy.

}

/**
* Clear the credentials and partial sign in session so the user can taken back to first Login step
*/
Expand Down Expand Up @@ -520,4 +525,5 @@ export {
setShouldShowComposeInput,
changePasswordAndSignIn,
invalidateCredentials,
invalidateAuthToken,
};
2 changes: 1 addition & 1 deletion src/pages/settings/PreferencesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const PreferencesPage = (props) => {
</View>

{/* If we are in the staging environment then we enable additional test features */}
{props.environment === CONST.ENVIRONMENT.STAGING && <TestToolMenu />}
{_.contains([CONST.ENVIRONMENT.STAGING, CONST.ENVIRONMENT.DEV], props.environment) && <TestToolMenu />}
</View>
</ScrollView>
</ScreenWrapper>
Expand Down