Skip to content

Commit

Permalink
remove duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
antonyr committed Jul 31, 2024
1 parent a320d30 commit 4e4f9ba
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions frontend/src/hooks/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const client = createClient<paths>({

const authMiddleware: Middleware = {
async onRequest({ request }) {
const accessToken = localStorage.getItem("AUTH");
const accessToken = localStorage.getItem(AUTH_KEY_ID);
if (!accessToken) {
throw new Error("No access token found");
}
Expand All @@ -68,15 +68,7 @@ export const AuthenticationProvider = (props: AuthenticationProviderProps) => {

// Add the API key to the request headers, if the user is authenticated.
if (apiKeyId !== null) {
client.use({
async onRequest({ request }) {
request.headers.set("Authorization", `Bearer ${apiKeyId}`);
return request;
},
async onResponse({ response }) {
return response;
},
});
client.use(authMiddleware);
}

const login = useCallback((apiKeyId: string) => {
Expand Down

0 comments on commit 4e4f9ba

Please sign in to comment.