feat: show password protection status in site settings
This commit is contained in:
@@ -56,6 +56,7 @@ export default function SiteSettingsPage() {
|
|||||||
const [scriptCopied, setScriptCopied] = useState(false)
|
const [scriptCopied, setScriptCopied] = useState(false)
|
||||||
const [linkCopied, setLinkCopied] = useState(false)
|
const [linkCopied, setLinkCopied] = useState(false)
|
||||||
const [showVerificationModal, setShowVerificationModal] = useState(false)
|
const [showVerificationModal, setShowVerificationModal] = useState(false)
|
||||||
|
const [isPasswordMasked, setIsPasswordMasked] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadSite()
|
loadSite()
|
||||||
@@ -73,6 +74,9 @@ export default function SiteSettingsPage() {
|
|||||||
password: '', // Don't show existing password
|
password: '', // Don't show existing password
|
||||||
excluded_paths: (data.excluded_paths || []).join('\n')
|
excluded_paths: (data.excluded_paths || []).join('\n')
|
||||||
})
|
})
|
||||||
|
if (data.has_password) {
|
||||||
|
setIsPasswordMasked(true)
|
||||||
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
toast.error('Failed to load site: ' + (error.message || 'Unknown error'))
|
toast.error('Failed to load site: ' + (error.message || 'Unknown error'))
|
||||||
} finally {
|
} finally {
|
||||||
@@ -94,7 +98,7 @@ export default function SiteSettingsPage() {
|
|||||||
name: formData.name,
|
name: formData.name,
|
||||||
timezone: formData.timezone,
|
timezone: formData.timezone,
|
||||||
is_public: formData.is_public,
|
is_public: formData.is_public,
|
||||||
password: formData.password || undefined,
|
password: isPasswordMasked ? undefined : (formData.password || undefined),
|
||||||
excluded_paths: excludedPathsArray
|
excluded_paths: excludedPathsArray
|
||||||
})
|
})
|
||||||
toast.success('Site updated successfully')
|
toast.success('Site updated successfully')
|
||||||
@@ -448,9 +452,20 @@ export default function SiteSettingsPage() {
|
|||||||
<input
|
<input
|
||||||
type="password"
|
type="password"
|
||||||
id="password"
|
id="password"
|
||||||
value={formData.password}
|
value={isPasswordMasked ? '********' : formData.password}
|
||||||
|
onFocus={() => {
|
||||||
|
if (isPasswordMasked) {
|
||||||
|
setIsPasswordMasked(false)
|
||||||
|
setFormData({ ...formData, password: '' })
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
if (!formData.password && site.has_password) {
|
||||||
|
setIsPasswordMasked(true)
|
||||||
|
}
|
||||||
|
}}
|
||||||
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
|
onChange={(e) => setFormData({ ...formData, password: e.target.value })}
|
||||||
placeholder="Leave empty to keep existing password (if any)"
|
placeholder={site.has_password ? "Change password" : "Leave empty to keep existing password (if any)"}
|
||||||
className="w-full px-4 py-2 border border-neutral-200 dark:border-neutral-800 rounded-xl bg-white dark:bg-neutral-900 text-neutral-900 dark:text-white focus:bg-white dark:focus:bg-neutral-900
|
className="w-full px-4 py-2 border border-neutral-200 dark:border-neutral-800 rounded-xl bg-white dark:bg-neutral-900 text-neutral-900 dark:text-white focus:bg-white dark:focus:bg-neutral-900
|
||||||
focus:border-brand-orange focus:ring-4 focus:ring-brand-orange/10 outline-none transition-all duration-200"
|
focus:border-brand-orange focus:ring-4 focus:ring-brand-orange/10 outline-none transition-all duration-200"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export interface Site {
|
|||||||
name: string
|
name: string
|
||||||
timezone?: string
|
timezone?: string
|
||||||
is_public?: boolean
|
is_public?: boolean
|
||||||
|
has_password?: boolean
|
||||||
excluded_paths?: string[]
|
excluded_paths?: string[]
|
||||||
created_at: string
|
created_at: string
|
||||||
updated_at: string
|
updated_at: string
|
||||||
|
|||||||
Reference in New Issue
Block a user