admin / Synapse-Cortex
publicSelf Hosted ITSM Tool with RBAC/Tenanting and MFA
Synapse-Cortex / Synapse-Cortexv2 / frontend / src / pages / MfaDisable.tsx
2404 B · main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import { useState, type FormEvent } from 'react' import { useNavigate } from 'react-router-dom' import { settingsApi } from '../api/settings' import { ApiError } from '../api/client' import { useAuth } from '../auth/AuthContext' import { usePageHeader } from '../layout/PageHeaderContext' export function MfaDisable() { usePageHeader('Settings // Disable MFA') const [password, setPassword] = useState('') const [error, setError] = useState<string | null>(null) const [submitting, setSubmitting] = useState(false) const navigate = useNavigate() const { refresh } = useAuth() const onSubmit = async (e: FormEvent) => { e.preventDefault() setError(null) setSubmitting(true) try { await settingsApi.mfaDisable(password) await refresh() navigate('/settings') } catch (err) { setError(err instanceof ApiError ? err.message : 'Current password is incorrect.') } finally { setSubmitting(false) } } return ( <div className="max-w-md border border-cortex-border bg-cortex-panel rounded-md p-6"> {error && ( <div className="mb-4 text-xs border border-accent-red/40 bg-accent-red/10 text-accent-red px-3 py-2 rounded"> {error} </div> )} <form onSubmit={onSubmit} className="space-y-3"> <div> <label className="block text-xs text-cortex-muted mb-1 uppercase tracking-wider"> Confirm Current Password </label> <input required type="password" value={password} onChange={(e) => setPassword(e.target.value)} className="w-full bg-cortex-panel2 border border-cortex-border rounded px-3 py-2 focus:outline-none focus:border-accent-blue" /> </div> <div className="flex gap-3"> <button type="submit" disabled={submitting} className="bg-accent-red text-cortex-bg font-display font-bold uppercase tracking-wider text-xs px-4 py-2 rounded hover:opacity-90 transition disabled:opacity-50" > Disable MFA </button> <button type="button" onClick={() => navigate('/settings')} className="text-xs text-cortex-muted hover:text-accent-blue transition" > Cancel </button> </div> </form> </div> ) } |