Handle token step
This commit is contained in:
@@ -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!)
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user