feat: login with password apis added

This commit is contained in:
مهرزاد قدرتی
2025-08-10 12:21:41 +03:30
parent 08bfe5c979
commit 945aa379ea
8 changed files with 108 additions and 23 deletions

View File

@@ -5,7 +5,11 @@ import { OtpVerifyForm } from './OtpVerifyForm';
import { isNumeric } from '@/utils/regexes/isNumeric';
import { CompleteSignUp } from './CompleteSignUp';
import { EnterPasswordForm } from './EnterPasswordForm';
import { getUserStatusByPhoneNumberOrEmail } from '../../api/authorizationAPI';
import {
getUserStatusByPhoneNumberOrEmail,
sendEmailOtp,
sendSmsOtp,
} from '../../api/authorizationAPI';
import { UserStatus } from '../../types/userTypes';
import type { CountryCode, GUID } from '@/types/commonTypes';
import { VerifyPhoneNumber } from './VerifyPhoneNumber';
@@ -51,11 +55,16 @@ export const AuthenticationSteps = (): JSX.Element => {
const handleOTPVerfied = (
registeredWithoutPhoneNumber: boolean = false,
userId: GUID,
returnUrl?: string,
) => {
localStorage.setItem('userID', userId);
// if (registeredWithoutPhoneNumber) {
// setCurrentStep('addPhoneNumber');
// }
if (returnUrl) {
location.href = returnUrl;
}
};
const handleEditValue = () => {
@@ -74,7 +83,17 @@ export const AuthenticationSteps = (): JSX.Element => {
setCurrentStep('emailOrPhone');
};
const handleLoggedInWithPassowrd = () => {};
const handleLoggedInWithPassowrd = (userId: GUID, returnUrl?: string) => {
localStorage.setItem('userID', userId);
if (returnUrl) {
location.href = returnUrl;
}
};
const handleLoginWithOtpInsteadOfPassword = async () => {
setCurrentStep('verify');
};
return (
<>
@@ -103,9 +122,12 @@ export const AuthenticationSteps = (): JSX.Element => {
{currentStep === 'enterPassword' && (
<EnterPasswordForm
loginRegisterValue={loginRegisterValue}
countryCode={countryCode}
authType={authType}
onLoggedIn={handleLoggedInWithPassowrd}
onEditValue={handleEditValue}
onLoginWithOTP={() => setCurrentStep('verify')}
onLoginWithOTP={handleLoginWithOtpInsteadOfPassword}
emailOrPhone={loginRegisterValue}
/>
)}