From 0cf3ae868f18f2b829ffdbae44b439ab797db60c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D8=B1=D8=B2=D8=A7=D8=AF=20=D9=82=D8=AF=D8=B1?= =?UTF-8?q?=D8=AA=DB=8C?= Date: Sat, 16 Aug 2025 15:55:40 +0330 Subject: [PATCH] chore: removing unused const and imports --- src/features/authorization/api/identityAPI.ts | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/features/authorization/api/identityAPI.ts b/src/features/authorization/api/identityAPI.ts index 0d20e01..efa3610 100644 --- a/src/features/authorization/api/identityAPI.ts +++ b/src/features/authorization/api/identityAPI.ts @@ -1,7 +1,6 @@ import apiClient from '@/lib/apiClient'; -import axios from 'axios'; -export interface GenerateToken { +export interface GenerateTokenWithPassword { username: string; password: string; } @@ -14,11 +13,9 @@ export interface GenerateTokenResponse { scope: string; } -const ACCESS_TOKEN_KEY: 'access_token' = 'access_token' as const; -const REFRESH_TOKEN_KEY: 'refresh_token' = 'refresh_token' as const; -const EXPIRES_IN_KEY: 'expires_in' = 'expires_in' as const; - -export const generateTokenWithPassword = (request: GenerateToken) => { +export const generateTokenWithPassword = ( + request: GenerateTokenWithPassword, +) => { const body = new URLSearchParams(); body.set('grant_type', 'password'); body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID); @@ -36,3 +33,27 @@ export const generateTokenWithPassword = (request: GenerateToken) => { }, ); }; + +export interface GenerateTokenWithOTP { + username: string; + otp: string; +} + +export const generateTokenWithOtp = (request: GenerateTokenWithOTP) => { + const body = new URLSearchParams(); + body.set('grant_type', 'otp'); + body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID); + body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE); + body.set('username', request.username); + body.set('otp', request.otp); + + return apiClient.post( + import.meta.env.VITE_IDENTITY_URL, + body.toString(), + { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + }, + ); +};