diff --git a/client/src/api/api.ts b/client/src/api/api.ts index 0409bf0..3b7226a 100644 --- a/client/src/api/api.ts +++ b/client/src/api/api.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import { Access, Auth } from '../types/auth'; +import { Auth, Tokens } from '../types/auth'; import { User } from '../types/user'; import { AuthService } from '../services/authService'; import axiosRetry from 'axios-retry'; @@ -70,23 +70,16 @@ base.interceptors.response.use( } ); -interface newAccess { - accessToken: string; - refreshToken: string; -} - const api = { // auth - // async login(auth: Auth): Promise { - async login(auth: Auth): Promise { - // const response = (await base.post) ('/auth', auth); - const response = await base.post('/auth', auth); + async login(auth: Auth): Promise { + const response = await base.post('/auth', auth); return response.data; }, - async refreshToken(): Promise { + async refreshToken(): Promise { const token = localStorage.getItem('refreshToken'); - const response = await base.post( + const response = await base.post( '/auth/refresh', {}, { diff --git a/client/src/services/authService.ts b/client/src/services/authService.ts index d24250d..e70e4cc 100644 --- a/client/src/services/authService.ts +++ b/client/src/services/authService.ts @@ -8,7 +8,7 @@ export class AuthService { static async login(auth: Auth) { const token = await api.login(auth); useAuthStore.getState().setAccessToken(token.accessToken); - localStorage.setItem('refreshToken', token.refreshToken); + localStorage.setItem('refreshToken', token.refreshToken as string); await UserService.getProfile().then((user) => { useUserStore.getState().setUser(user); }); diff --git a/client/src/types/auth.ts b/client/src/types/auth.ts index f1ac5a4..8e0f549 100644 --- a/client/src/types/auth.ts +++ b/client/src/types/auth.ts @@ -1,4 +1,4 @@ import { components } from './openapi-types'; export type Auth = components['schemas']['Auth']; -export type Access = components['schemas']['Access']; +export type Tokens = components['schemas']['Tokens']; diff --git a/client/src/types/openapi-types.ts b/client/src/types/openapi-types.ts index 7e7f9e6..b23e43f 100644 --- a/client/src/types/openapi-types.ts +++ b/client/src/types/openapi-types.ts @@ -120,11 +120,6 @@ export interface paths { export type webhooks = Record; export interface components { schemas: { - /** Access */ - Access: { - /** Accesstoken */ - accessToken: string; - }; /** AccountKeyring */ AccountKeyring: { /** Ownerid */ @@ -219,6 +214,13 @@ export interface components { * @enum {string} */ KeyType: "PASSWORD" | "ACCESS_TOKEN" | "REFRESH_TOKEN" | "API_KEY"; + /** Tokens */ + Tokens: { + /** Accesstoken */ + accessToken: string; + /** Refreshtoken */ + refreshToken?: string | null; + }; /** User */ User: { /** Id */ @@ -305,7 +307,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["Access"]; + "application/json": components["schemas"]["Tokens"]; }; }; /** @description Validation Error */ @@ -334,7 +336,7 @@ export interface operations { [name: string]: unknown; }; content: { - "application/json": components["schemas"]["Access"]; + "application/json": components["schemas"]["Tokens"]; }; }; };