Handle token step

This commit is contained in:
Eric Bailey
2025-04-25 15:34:56 -05:00
parent 4a7c4fd215
commit 90cb1ac41f
2 changed files with 105 additions and 9 deletions
@@ -0,0 +1,22 @@
import {useMutation} from '@tanstack/react-query'
import {useAgent, useSession} from '#/state/session'
export function useConfirmEmail() {
const agent = useAgent()
const {currentAccount} = useSession()
return useMutation({
mutationFn: async ({token}: {token: string}) => {
if (!currentAccount?.email) {
throw new Error('No email found for the current account')
}
await agent.com.atproto.server.confirmEmail({
email: currentAccount.email,
token: token.trim(),
})
await agent.resumeSession(agent.session!)
},
})
}