Something went wrong. Try again.
Bluesky app fork with some witchin' additions 💫 forked from jollywhoppers.com/witchsky.app
Something went wrong. Try again.
809 B · 30 lines
TypeScript
at main
12345678910111213141516171819202122232425262728293031import {useMutation} from '@tanstack/react-query'
import {useAgent, useSession} from '#/state/session'import {pdsAgent} from '#/state/session/agent'
export function useManageEmail2FA() { const agent = useAgent() const {currentAccount} = useSession()
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 pdsAgent(agent).com.atproto.server.updateEmail({ email: currentAccount.email, emailAuthFactor: enabled, token, }) // will update session state at root of app await agent.resumeSession(agent.session!) }, })}