hotfix: generateTokenWithOtp request change
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user