Skip to content

Commit

Permalink
- add AuthRefreshProvider to refresh auth tokens every 5 minutes
Browse files Browse the repository at this point in the history
- pull the latest crowdin language artifacts
  • Loading branch information
AmruthPillai committed May 10, 2024
1 parent b0d26e3 commit c1a5811
Show file tree
Hide file tree
Showing 34 changed files with 5,798 additions and 4,007 deletions.
12 changes: 3 additions & 9 deletions apps/client/src/libs/axios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _axios from "axios";
import createAuthRefreshInterceptor from "axios-auth-refresh";
import { redirect } from "react-router-dom";

import { refresh } from "@/client/services/auth";
import { refreshToken } from "@/client/services/auth";

import { USER_KEY } from "../constants/query-keys";
import { toast } from "../hooks/use-toast";
Expand Down Expand Up @@ -40,18 +40,12 @@ axios.interceptors.response.use(
const axiosForRefresh = _axios.create({ baseURL: "/api", withCredentials: true });

// Interceptor to handle expired access token errors
const handleAuthError = async () => {
await refresh(axiosForRefresh);

await Promise.resolve();
};
const handleAuthError = () => refreshToken(axiosForRefresh);

// Interceptor to handle expired refresh token errors
const handleRefreshError = async () => {
void queryClient.invalidateQueries({ queryKey: USER_KEY });
await queryClient.invalidateQueries({ queryKey: USER_KEY });
redirect("/auth/login");

await Promise.resolve();
};

// Intercept responses to check for 401 and 403 errors, refresh token and retry the request
Expand Down
294 changes: 147 additions & 147 deletions apps/client/src/locales/ar-SA/messages.po

Large diffs are not rendered by default.

746 changes: 373 additions & 373 deletions apps/client/src/locales/bg-BG/messages.po

Large diffs are not rendered by default.

Loading

0 comments on commit c1a5811

Please sign in to comment.