Something went wrong. Try again.
Mirror — see github.com/blacksky-algorithms/blacksky.community
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132import {useMutation} from '@tanstack/react-query'
import {useAgent, useSession} from '#/state/session'import {useRefreshSession} from '#/state/session/useRefreshSession'
export function useManageEmail2FA() { const agent = useAgent() const {currentAccount} = useSession() const refreshSession = useRefreshSession()
return useMutation({ mutationFn: async ({ enabled, token, }: | {enabled: true; token?: undefined} | {enabled: false; token: string}) => { if (!currentAccount?.email) { throw new Error('No email found for the current account') }
await agent.com.atproto.server.updateEmail({ email: currentAccount.email, emailAuthFactor: enabled, token, }) // will update session state at root of app await refreshSession() }, })}