Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions nextjs/src/features/passkey/PassKeyAddDevice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ import { Field, Form, Formik } from 'formik'
import { AxiosResponse } from 'axios'
import { Button } from '@/components/ui/button'
import { Input } from '@/components/ui/input'
import { RootState } from '@/lib/store'
import { addPasskeyUserDetails } from '@/app/api/Fido'
import { apiStatusCodes } from '@/config/CommonConstant'
import { passwordEncryption } from '@/app/api/Auth'
import { useSelector } from 'react-redux'
import { useState } from 'react'

interface PasswordValue {
Expand All @@ -31,10 +29,12 @@ interface PasskeyAddDeviceProps {
setOpenModel: (flag: boolean) => void
closeModal: (flag: boolean) => void
registerWithPasskey: (flag: boolean) => Promise<void>
email: string | undefined
}

export default function PasskeyAddDevice({
openModal,
email,
setOpenModel,
registerWithPasskey,
}: PasskeyAddDeviceProps): React.JSX.Element {
Expand All @@ -43,7 +43,7 @@ export default function PasskeyAddDevice({
const [nextStep, setNextStep] = useState(false)
const [passwordVisible, setPasswordVisible] = useState(false)

const userEmail = useSelector((state: RootState) => state.profile.email)
const userEmail = email
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'const userEmail = email' assumes email is provided. Add a guard to prevent runtime errors if email is undefined.

Suggested change
const userEmail = email
const userEmail = email ?? ""

const savePassword = async (values: PasswordValue): Promise<void> => {
try {
const payload = {
Expand Down
Loading