Skip to content

Commit

Permalink
Merge pull request #4278 from mozilla/MNTOR-2995
Browse files Browse the repository at this point in the history
MNTOR-2995: not having fxa tokens shouldn't return 500
  • Loading branch information
mansaj authored Feb 28, 2024
2 parents d457db9 + 99ce46b commit d366faf
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/app/api/v1/fxa-rp-events/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,25 +254,27 @@ export async function POST(request: NextRequest) {
updateFromEvent,
});

const refreshToken = subscriber.fxa_refresh_token;
const accessToken = subscriber.fxa_access_token;
if (refreshToken === null || accessToken === null) {
const refreshToken = subscriber.fxa_refresh_token ?? "";
const accessToken = subscriber.fxa_access_token ?? "";
if (accessToken === null || refreshToken === null) {
logger.error("failed_changing_password", {
subscriber_id: subscriber.id,
fxa_refresh_token: subscriber.fxa_refresh_token,
fxa_access_token: subscriber.fxa_access_token,
});
return NextResponse.json(
{ success: false, message: "failed_changing_password" },
{ status: 500 },
);
}

// MNTOR-1932: Change password should revoke sessions
await revokeOAuthTokens({
fxa_access_token: accessToken,
fxa_refresh_token: refreshToken,
});

return NextResponse.json(
{ success: true, message: "session_revoked" },
{ status: 200 },
);

break;
}
case FXA_SUBSCRIPTION_CHANGE_EVENT: {
Expand Down

0 comments on commit d366faf

Please sign in to comment.