Skip to content

7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.

TypeScript

feat(auth): add password visibility toggle (#1585)

Alexis Corporal53276095480b
diff --git a/client/src/components/auth-gate.tsx b/client/src/components/auth-gate.tsx
index 26daf8e2..48087be6 100644
--- a/client/src/components/auth-gate.tsx
+++ b/client/src/components/auth-gate.tsx
@@ -5,6 +5,7 @@ import { apiFetch, setToken, UNAUTHORIZED_EVENT, type ApiError } from '@/lib/api
import { Button } from '@/components/ui/button'
import { FieldError } from '@/components/ui/field-error'
import { Input } from '@/components/ui/input'
+import { PasswordInput } from '@/components/ui/password-input'
import { Label } from '@/components/ui/label'
import { isEmail } from '@/lib/validate'
import { useI18n } from '@/i18n'
@@ -157,9 +158,8 @@ function AuthForm({ mode, onAuthed }: { mode: 'setup' | 'login'; onAuthed: () =>
</div>
<div className="space-y-1.5">
<Label className="text-xs" htmlFor="auth-password">{t('auth.password')}</Label>
- <Input
+ <PasswordInput
id="auth-password"
- type="password"
autoComplete={isSetup ? 'new-password' : 'current-password'}
value={password}
onChange={e => setPassword(e.target.value)}
@@ -309,9 +309,8 @@ function ForgotPasswordForm({ onBack, onAuthed }: { onBack: () => void; onAuthed
</div>
<div className="space-y-1.5">
<Label className="text-xs" htmlFor="reset-new-password">{t('auth.newPassword')}</Label>
- <Input
+ <PasswordInput
id="reset-new-password"
- type="password"
autoComplete="new-password"
value={newPassword}
onChange={e => setNewPassword(e.target.value)}
@@ -411,9 +410,8 @@ export function ChangeCredentialsModal({ mode, onClose }: ChangeCredentialsModal
<form onSubmit={submit} className="space-y-3 mt-4" noValidate>
<div className="space-y-1.5">
<Label className="text-xs" htmlFor="cred-current-password">{t('auth.currentPassword')}</Label>
- <Input
+ <PasswordInput
id="cred-current-password"
- type="password"
autoComplete="current-password"
value={currentPassword}
onChange={e => setCurrentPassword(e.target.value)}
@@ -426,15 +424,22 @@ export function ChangeCredentialsModal({ mode, onClose }: ChangeCredentialsModal
<Label className="text-xs" htmlFor="cred-new-value">
{isPassword ? t('auth.newPassword') : t('auth.newEmail')}
</Label>
- <Input
+ {isPassword ? <PasswordInput
id="cred-new-value"
- type={isPassword ? 'password' : 'email'}
- autoComplete={isPassword ? 'new-password' : 'email'}
+ autoComplete="new-password"
value={newValue}
onChange={e => setNewValue(e.target.value)}
- placeholder={isPassword ? t('auth.passwordPlaceholderSetup') : t('auth.emailPlaceholder')}
+ placeholder={t('auth.passwordPlaceholderSetup')}
aria-invalid={attempted && !!newValueError}
- />
+ /> : <Input
+ id="cred-new-value"
+ type="email"
+ autoComplete="email"
+ value={newValue}
+ onChange={e => setNewValue(e.target.value)}
+ placeholder={t('auth.emailPlaceholder')}
+ aria-invalid={attempted && !!newValueError}
+ />}
{attempted && <FieldError error={newValueError} />}
</div>
{error && <p className="text-destructive text-xs">{error}</p>}
diff --git a/client/src/components/ui/password-input.tsx b/client/src/components/ui/password-input.tsx
new file mode 100644
index 00000000..b8aceb5f
--- /dev/null
+++ b/client/src/components/ui/password-input.tsx
@@ -0,0 +1,27 @@
+import { useState, type ComponentProps } from 'react'
+import { Eye, EyeOff } from 'lucide-react'
+import { Input } from '@/components/ui/input'
+import { cn } from '@/lib/utils'
+
+function PasswordInput(props: Omit<ComponentProps<typeof Input>, 'type'>) {
+ const [visible, setVisible] = useState(false)
+
+ return (
+ <div className="relative">
+ <Input {...props} type={visible ? 'text' : 'password'} className={cn('pr-9', props.className)} />
+ <button
+ type="button"
+ aria-label={visible ? 'Hide password' : 'Show password'}
+ title={visible ? 'Hide password' : 'Show password'}
+ aria-pressed={visible}
+ onMouseDown={e => e.preventDefault()}
+ onClick={() => setVisible(value => !value)}
+ className="absolute inset-y-0 right-1 inline-flex w-7 items-center justify-center rounded-md text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
+ >
+ {visible ? <EyeOff aria-hidden className="size-4" /> : <Eye aria-hidden className="size-4" />}
+ </button>
+ </div>
+ )
+}
+
+export { PasswordInput }