hotfix: generateTokenWithOtp request change
This commit is contained in:
@@ -35,7 +35,8 @@ export const generateTokenWithPassword = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export interface GenerateTokenWithOTP {
|
export interface GenerateTokenWithOTP {
|
||||||
username: string;
|
email?: string;
|
||||||
|
phonenumber?: string;
|
||||||
otp: string;
|
otp: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,8 +45,9 @@ export const generateTokenWithOtp = (request: GenerateTokenWithOTP) => {
|
|||||||
body.set('grant_type', 'otp');
|
body.set('grant_type', 'otp');
|
||||||
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
body.set('client_id', import.meta.env.VITE_IDENTITY_CLIENT_ID);
|
||||||
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
body.set('scope', import.meta.env.VITE_IDENTITY_SCOPE);
|
||||||
body.set('username', request.username);
|
if (request.email) body.set('email', request.email);
|
||||||
body.set('otp', request.otp);
|
if (request.phonenumber) body.set('phonenumber', request.phonenumber);
|
||||||
|
body.set('otp_code', request.otp);
|
||||||
|
|
||||||
return apiClient.post<GenerateTokenResponse>(
|
return apiClient.post<GenerateTokenResponse>(
|
||||||
import.meta.env.VITE_IDENTITY_URL,
|
import.meta.env.VITE_IDENTITY_URL,
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export const EnterPasswordForm = ({
|
|||||||
|
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
|
|
||||||
if (loginWithPassResult.success) {
|
if (res.success) {
|
||||||
const tokenRes = await generateTokenWithPassword({
|
const tokenRes = await generateTokenWithPassword({
|
||||||
username: apiRequest.email ?? (apiRequest.phoneNumber as string),
|
username: apiRequest.email ?? (apiRequest.phoneNumber as string),
|
||||||
password: apiRequest.password,
|
password: apiRequest.password,
|
||||||
@@ -90,7 +90,7 @@ export const EnterPasswordForm = ({
|
|||||||
...tokenRes.data,
|
...tokenRes.data,
|
||||||
});
|
});
|
||||||
|
|
||||||
onLoggedIn(loginWithPassResult.userId);
|
onLoggedIn(res.userId);
|
||||||
toast({
|
toast({
|
||||||
message: t('verify.youHaveSuccessfullyLoggedIn'),
|
message: t('verify.youHaveSuccessfullyLoggedIn'),
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
import type { CountryCode, GUID } from '@/types/commonTypes';
|
import type { CountryCode, GUID } from '@/types/commonTypes';
|
||||||
import { Icon, useToast } from '@rkheftan/harmony-ui';
|
import { Icon, useToast } from '@rkheftan/harmony-ui';
|
||||||
import { useApi } from '@/hooks/useApi';
|
import { useApi } from '@/hooks/useApi';
|
||||||
|
import { generateTokenWithOtp } from '../../api/identityAPI';
|
||||||
|
import { useAuth } from '@/hooks/useAuth';
|
||||||
|
|
||||||
interface OtpVerifyFormProps {
|
interface OtpVerifyFormProps {
|
||||||
value: string;
|
value: string;
|
||||||
@@ -49,6 +51,7 @@ export function OtpVerifyForm({
|
|||||||
useApi(sendEmailOtp);
|
useApi(sendEmailOtp);
|
||||||
const { loading: loginSignUpLoading, execute: loginSignUpCall } =
|
const { loading: loginSignUpLoading, execute: loginSignUpCall } =
|
||||||
useApi(loginOrSignUpWithOtp);
|
useApi(loginOrSignUpWithOtp);
|
||||||
|
const auth = useAuth();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let interval: NodeJS.Timeout;
|
let interval: NodeJS.Timeout;
|
||||||
@@ -106,6 +109,15 @@ export function OtpVerifyForm({
|
|||||||
if (res.success) {
|
if (res.success) {
|
||||||
setIsStatusSuccess(true);
|
setIsStatusSuccess(true);
|
||||||
|
|
||||||
|
const tokenRes = await generateTokenWithOtp({
|
||||||
|
email: loginRequest.email,
|
||||||
|
phonenumber: loginRequest.phoneNumber,
|
||||||
|
otp: loginRequest.otpCode,
|
||||||
|
});
|
||||||
|
auth.login({
|
||||||
|
...tokenRes.data,
|
||||||
|
});
|
||||||
|
|
||||||
if (res.registeredWithOutPhoneNumber) {
|
if (res.registeredWithOutPhoneNumber) {
|
||||||
onVerifyPhoneNumber(res.userId);
|
onVerifyPhoneNumber(res.userId);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const apiClient = axios.create({
|
|||||||
baseURL: import.meta.env.VITE_API_URL,
|
baseURL: import.meta.env.VITE_API_URL,
|
||||||
|
|
||||||
// Set a timeout for requests (e.g., 10 seconds)
|
// Set a timeout for requests (e.g., 10 seconds)
|
||||||
timeout: 10000,
|
timeout: 30000,
|
||||||
|
|
||||||
// Set default headers
|
// Set default headers
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user