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

Prompt for reauth in case of 498 drop #2883

Merged
merged 1 commit into from
Sep 9, 2024
Merged
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
12 changes: 11 additions & 1 deletion packages/snjs/lib/Services/Api/ApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,17 @@ export class LegacyApiService
}

private preprocessAuthenticatedErrorResponse(response: HttpResponse) {
if (response.status === HttpStatusCode.Unauthorized && this.session) {
if (!this.session) {
return
}

/**
* In most cases the ExpiredAccessToken erorr shouldn't reach this function, since if a 498 is caught, a refresh
* will automatically take place. However there does appear to be rare cases where for some reason the 498 falls through,
* perhaps because for example the server responds to a refresh request with a 498. In those cases, we'll just
* fallback here to the invalid session observer so that the user can be reprompted for auth.
*/
if (response.status === HttpStatusCode.Unauthorized || response.status === HttpStatusCode.ExpiredAccessToken) {
this.invalidSessionObserver?.(response.data.error?.tag === ErrorTag.RevokedSession)
}
}
Expand Down
Loading