Skip to content

Commit

Permalink
Fix invalidated tokens not being cleared from storage (#354)
Browse files Browse the repository at this point in the history
This is an emergency hotfix related to lemmy.world revoking
login tokens.
  • Loading branch information
aeharding authored Jul 10, 2023
1 parent 4791314 commit 9d51cf4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/features/auth/authSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,22 @@ export const login =
export const getSite =
() => async (dispatch: AppDispatch, getState: () => RootState) => {
const jwtPayload = jwtPayloadSelector(getState());
const handle = handleSelector(getState());

if (!jwtPayload) return;
if (!jwtPayload || !handle) return;

const { iss } = jwtPayload;

const details = await getClient(iss).getSite({
auth: jwtSelector(getState()),
});

// JWT was revoked or invalid, log out user
if (!details.my_user) {
await dispatch(logoutAccount(handle));
return;
}

dispatch(updateUserDetails(details));
};

Expand Down

0 comments on commit 9d51cf4

Please sign in to comment.