chore: removing unused const and imports
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import apiClient from '@/lib/apiClient';
|
import apiClient from '@/lib/apiClient';
|
||||||
import axios from 'axios';
|
|
||||||
|
|
||||||
export interface GenerateToken {
|
export interface GenerateTokenWithPassword {
|
||||||
username: string;
|
username: string;
|
||||||
password: string;
|
password: string;
|
||||||
}
|
}
|
||||||
@@ -14,11 +13,9 @@ export interface GenerateTokenResponse {
|
|||||||
scope: string;
|
scope: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ACCESS_TOKEN_KEY: 'access_token' = 'access_token' as const;
|
export const generateTokenWithPassword = (
|
||||||
const REFRESH_TOKEN_KEY: 'refresh_token' = 'refresh_token' as const;
|
request: GenerateTokenWithPassword,
|
||||||
const EXPIRES_IN_KEY: 'expires_in' = 'expires_in' as const;
|
) => {
|
||||||
|
|
||||||
export const generateTokenWithPassword = (request: GenerateToken) => {
|
|
||||||
const body = new URLSearchParams();
|
const body = new URLSearchParams();
|
||||||
body.set('grant_type', 'password');
|
body.set('grant_type', 'password');
|
||||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
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<GenerateTokenResponse>(
|
||||||
|
import.meta.env.VITE_IDENTITY_URL,
|
||||||
|
body.toString(),
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/x-www-form-urlencoded',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user