Skip to content

Commit

Permalink
AnonymousForm.tsx: Disable field if user is logged in (#1448)
Browse files Browse the repository at this point in the history
Preventive measure against logged users supplying different email - donation remains anonymous
sashko9807 authored Jun 19, 2023
1 parent f93ef65 commit 0b349dd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/client/one-time-donation/AnonymousForm.tsx
Original file line number Diff line number Diff line change
@@ -2,9 +2,12 @@ import * as React from 'react'
import { useTranslation } from 'next-i18next'
import { Grid, Typography } from '@mui/material'
import EmailField from 'components/common/form/EmailField'
import { useSession } from 'next-auth/react'

export default function AnonymousForm() {
const { t } = useTranslation('one-time-donation')
const { data: session } = useSession()
const isLogged = session?.accessToken ? true : false
return (
<>
<Typography variant="subtitle2" fontWeight="bold">
@@ -16,7 +19,13 @@ export default function AnonymousForm() {
<Typography>{t('anonymous-menu.info-start')}</Typography>
</Grid>
<Grid item xs={12} md={12}>
<EmailField name="personsEmail" label="Email" fullWidth />
<EmailField
name="personsEmail"
label="Email"
fullWidth
value={isLogged ? session?.user?.email : null}
disabled={isLogged ? true : false}
/>
</Grid>
</Grid>
</>

0 comments on commit 0b349dd

Please sign in to comment.