hotfix: generateTokenWithOtp request change

This commit is contained in:
مهرزاد قدرتی
2025-08-16 16:40:09 +03:30
parent 14fb717c52
commit dd6e2fdd0d
4 changed files with 20 additions and 6 deletions

View File

@@ -35,7 +35,8 @@ export const generateTokenWithPassword = (
};
export interface GenerateTokenWithOTP {
username: string;
email?: string;
phonenumber?: string;
otp: string;
}
@@ -44,8 +45,9 @@ export const generateTokenWithOtp = (request: GenerateTokenWithOTP) => {
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);
if (request.email) body.set('email', request.email);
if (request.phonenumber) body.set('phonenumber', request.phonenumber);
body.set('otp_code', request.otp);
return apiClient.post<GenerateTokenResponse>(
import.meta.env.VITE_IDENTITY_URL,

View File

@@ -81,7 +81,7 @@ export const EnterPasswordForm = ({
if (!res) return;
if (loginWithPassResult.success) {
if (res.success) {
const tokenRes = await generateTokenWithPassword({
username: apiRequest.email ?? (apiRequest.phoneNumber as string),
password: apiRequest.password,
@@ -90,7 +90,7 @@ export const EnterPasswordForm = ({
...tokenRes.data,
});
onLoggedIn(loginWithPassResult.userId);
onLoggedIn(res.userId);
toast({
message: t('verify.youHaveSuccessfullyLoggedIn'),
severity: 'success',

View File

@@ -14,6 +14,8 @@ import {
import type { CountryCode, GUID } from '@/types/commonTypes';
import { Icon, useToast } from '@rkheftan/harmony-ui';
import { useApi } from '@/hooks/useApi';
import { generateTokenWithOtp } from '../../api/identityAPI';
import { useAuth } from '@/hooks/useAuth';
interface OtpVerifyFormProps {
value: string;
@@ -49,6 +51,7 @@ export function OtpVerifyForm({
useApi(sendEmailOtp);
const { loading: loginSignUpLoading, execute: loginSignUpCall } =
useApi(loginOrSignUpWithOtp);
const auth = useAuth();
useEffect(() => {
let interval: NodeJS.Timeout;
@@ -106,6 +109,15 @@ export function OtpVerifyForm({
if (res.success) {
setIsStatusSuccess(true);
const tokenRes = await generateTokenWithOtp({
email: loginRequest.email,
phonenumber: loginRequest.phoneNumber,
otp: loginRequest.otpCode,
});
auth.login({
...tokenRes.data,
});
if (res.registeredWithOutPhoneNumber) {
onVerifyPhoneNumber(res.userId);
} else {

View File

@@ -6,7 +6,7 @@ const apiClient = axios.create({
baseURL: import.meta.env.VITE_API_URL,
// Set a timeout for requests (e.g., 10 seconds)
timeout: 10000,
timeout: 30000,
// Set default headers
headers: {