issue #33
All checks were successful
Test CI / build (push) Successful in 19s

- 로그인 요청 후 응답을 AuthData 로 저장 로직 구현
- Access/Refresh 토큰 구현 중
This commit is contained in:
geonhee-min
2025-12-01 16:22:40 +09:00
parent 877bbc582e
commit 45dc4cbaaa
11 changed files with 97 additions and 34 deletions

View File

@@ -20,22 +20,51 @@ export class AccountNetwork extends BaseNetwork {
async checkDuplication(data: CheckDuplicationRequest) {
const { type, value } = data;
return await this.instance.get<CheckDuplicationResponse>(`${this.baseUrl}/check-duplication?type=${type}&value=${value}`);
return await this.get<CheckDuplicationResponse>(
`${this.baseUrl}/check-duplication?type=${type}&value=${value}`
, {
authPass: true
}
);
}
async sendVerificationCode(data: SendVerificationCodeRequest) {
return await this.instance.post<SendVerificationCodeResponse>(this.baseUrl + "/send-verification-code", data);
return await this.post<SendVerificationCodeResponse>(
this.baseUrl + "/send-verification-code"
, data
, {
authPass: true
}
);
}
async verifyCode(data: VerifyCodeRequest) {
return await this.instance.post<VerifyCodeResponse>(this.baseUrl + "/verify-code", data);
return await this.post<VerifyCodeResponse>(
this.baseUrl + "/verify-code"
, data
, {
authPass: true
}
);
}
async signup(data: SignupRequest) {
return await this.instance.post<SignupResponse>(this.baseUrl + "/signup", data);
return await this.post<SignupResponse>(
this.baseUrl + "/signup"
, data
, {
authPass: true
}
);
}
async login(data: LoginRequest) {
return await this.instance.post<LoginResponse>(this.baseUrl + "/login", data);
return await this.post<LoginResponse>(
this.baseUrl + "/login"
, data
, {
authPass: true
}
);
}
}

View File

@@ -4,6 +4,7 @@ import type {
AxiosRequestConfig,
AxiosError,
AxiosResponse,
InternalAxiosRequestConfig,
} from "axios";
export class BaseNetwork {
@@ -29,12 +30,15 @@ export class BaseNetwork {
// ★ 요청 인터셉터
this.instance.interceptors.request.use(
(config) => {
// 예: 자동 토큰 추가
// const token = localStorage.getItem("token");
// if (token) {
// config.headers.Authorization = `Bearer ${token}`;
// }
const reqConfig = config as InternalAxiosRequestConfig & { authPass?: boolean };
if (reqConfig.authPass) {
return config;
}
const accessToken = localStorage.getItem("accessToken");
if (accessToken) {
config.headers.Authorization = `Bearer ${accessToken}`;
}
return config;
},
(error: AxiosError) => Promise.reject(error)
@@ -61,11 +65,11 @@ export class BaseNetwork {
/**
* 기본 CRUD 메서드
*/
protected async get<T = any>(url: string, config?: AxiosRequestConfig) {
protected async get<T = any>(url: string, config?: AxiosRequestConfig & { authPass?: boolean }) {
return await this.instance.get<T>(url, config);
}
protected async post<T = any>(url: string, data?: any, config?: AxiosRequestConfig) {
protected async post<T = any>(url: string, data?: any, config?: AxiosRequestConfig & { authPass?: boolean }) {
return await this.instance.post<T>(url, data, config);
}
}