feat(client): profile improvements
Signed-off-by: Noa Virellia <noa@requiem.garden>
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import { isEmpty, isNil } from 'lodash-es';
|
||||
import { client } from '@/client/client.gen';
|
||||
import { router } from './router';
|
||||
import {
|
||||
getToken,
|
||||
getRefreshToken,
|
||||
setToken,
|
||||
setRefreshToken,
|
||||
clearTokens,
|
||||
doRefreshToken
|
||||
} from "./token";
|
||||
import { router } from "./router";
|
||||
import { isEmpty,
|
||||
isNil } from "lodash-es";
|
||||
import { client } from "@/client/client.gen";
|
||||
doRefreshToken,
|
||||
getRefreshToken,
|
||||
getToken,
|
||||
setRefreshToken,
|
||||
setToken,
|
||||
} from './token';
|
||||
|
||||
export function configInternalApiClient() {
|
||||
client.setConfig({
|
||||
@@ -50,7 +49,8 @@ export function configInternalApiClient() {
|
||||
signal: request.signal,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
clearTokens();
|
||||
await router.navigate({ to: '/authorize' });
|
||||
return response;
|
||||
@@ -59,5 +59,4 @@ export function configInternalApiClient() {
|
||||
}
|
||||
return response;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { postAuthRefresh, type ServiceAuthTokenResponse } from '@/client';
|
||||
import type { ServiceAuthTokenResponse } from '@/client';
|
||||
import { postAuthRefresh } from '@/client';
|
||||
|
||||
export function setToken(token: string) {
|
||||
localStorage.setItem('token', token);
|
||||
@@ -32,8 +33,8 @@ export function clearTokens() {
|
||||
export async function doRefreshToken(): Promise<ServiceAuthTokenResponse | undefined> {
|
||||
const { data } = await postAuthRefresh({
|
||||
body: {
|
||||
refresh_token: getRefreshToken()!
|
||||
}
|
||||
refresh_token: getRefreshToken()!,
|
||||
},
|
||||
});
|
||||
return data?.data;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user