Skip to content

Commit

Permalink
fix: remove username (#306)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickimoore authored Feb 11, 2025
1 parent cf538e8 commit 68d74e1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
4 changes: 1 addition & 3 deletions app/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const Main = () => {
const [isReady, setReady] = useState(false)
const [isVersionError, setVersionError] = useState(false)
const [isAuthenticated, setIsAuthenticated] = useState(false)
const [, setUsername] = useLocalStorage<string>('username', 'Keeper')
const [healthCheck] = useLocalStorage<boolean>('health-check', false)

const [beaconNodeVersion, setBeaconVersion] = useState('')
Expand Down Expand Up @@ -77,10 +76,9 @@ const Main = () => {
? formatSemanticVersion(beaconNodeVersion as string)
: undefined

const storeSessionCookie = async (password: string, username: string) => {
const storeSessionCookie = async (password: string) => {
try {
setLoading(true)
setUsername(username)
const { status } = await axios.post('/api/authenticate', { password })

if (status === 200) {
Expand Down
21 changes: 1 addition & 20 deletions src/components/AuthPrompt/AuthPrompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Typography from '../Typography/Typography'
export interface AuthModalProps extends Omit<AuthFormProps, 'children'> {
isVisible: boolean
isLoading: boolean
isNamePrompt?: boolean
onClose?: () => void
mode: UiMode
}
Expand All @@ -24,7 +23,6 @@ const AuthPrompt: FC<AuthModalProps> = ({
isLoading,
mode,
onClose,
isNamePrompt,
}) => {
const { t } = useTranslation()
const [isReady, setReady] = useState(false)
Expand Down Expand Up @@ -58,23 +56,6 @@ const AuthPrompt: FC<AuthModalProps> = ({
</Typography>
</div>
<div className='space-y-4'>
{isNamePrompt && (
<Controller
name='username'
control={control as any}
render={({ field: { ref: _ref, ...props }, fieldState }) => (
<Input
tooltip={t('authPrompt.tooltip.displayName')}
toolTipId='displayName'
toolTipMode={UiMode.LIGHT}
label={t('authPrompt.label.name')}
uiMode={mode}
error={fieldState.error?.message}
{...props}
/>
)}
/>
)}
<Controller
name='password'
control={control as any}
Expand All @@ -83,7 +64,7 @@ const AuthPrompt: FC<AuthModalProps> = ({
isAutoFocus
tooltip={t('authPrompt.tooltip.sessionPassword')}
toolTipId='sessionPassword'
label={isNamePrompt ? t('authPrompt.label.sessionPassword') : undefined}
label={t('authPrompt.label.sessionPassword')}
autoComplete='new-password'
type='password'
uiMode={mode}
Expand Down
9 changes: 2 additions & 7 deletions src/forms/AuthenticationForm.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { FC, FormEvent, ReactElement, useEffect } from 'react'
import { Control, useForm } from 'react-hook-form'
import useLocalStorage from '../hooks/useLocalStorage'

export interface AuthFormProps {
children: (props: RenderProps) => ReactElement
onSubmit: (token: string, username: string) => void
onSubmit: (token: string) => void
isVisible: boolean
}

export interface AuthForm {
username: string
password: string
}

Expand All @@ -19,11 +17,9 @@ export interface RenderProps {
}

const AuthenticationForm: FC<AuthFormProps> = ({ children, onSubmit, isVisible }) => {
const [username] = useLocalStorage<string>('username', 'Keeper')

const { control, watch, reset } = useForm<AuthForm>({
defaultValues: {
username,
password: '',
},
mode: 'onChange',
Expand All @@ -36,12 +32,11 @@ const AuthenticationForm: FC<AuthFormProps> = ({ children, onSubmit, isVisible }
}, [isVisible, reset])

const password = watch('password')
const name = watch('username')

const submitForm = (e: FormEvent) => {
e.preventDefault()
if (password) {
onSubmit(password, name)
onSubmit(password)
}
}

Expand Down

0 comments on commit 68d74e1

Please sign in to comment.