migrate the pre-auth service calls to the service client
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import {useCallback, useState} from 'react'
|
||||
import {Keyboard, View} from 'react-native'
|
||||
import {type ComAtprotoServerDescribeServer} from '@atproto/api'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
import * as EmailValidator from 'email-validator'
|
||||
|
||||
import {createServiceClient} from '#/lib/lexClient'
|
||||
import {cleanError, isNetworkError} from '#/lib/strings/errors'
|
||||
import {logger} from '#/logger'
|
||||
import {Agent} from '#/state/session/agent'
|
||||
import {atoms as a, useTheme, web} from '#/alf'
|
||||
import {Admonition} from '#/components/Admonition'
|
||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
@@ -16,9 +15,10 @@ import {At_Stroke2_Corner0_Rounded as At} from '#/components/icons/At'
|
||||
import {Loader} from '#/components/Loader'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {IS_WEB} from '#/env'
|
||||
import {com} from '#/lexicons'
|
||||
import {FormContainer} from './FormContainer'
|
||||
|
||||
type ServiceDescription = ComAtprotoServerDescribeServer.OutputSchema
|
||||
type ServiceDescription = com.atproto.server.describeServer.$OutputBody
|
||||
|
||||
export const ForgotPasswordForm = ({
|
||||
error,
|
||||
@@ -55,8 +55,12 @@ export const ForgotPasswordForm = ({
|
||||
setIsProcessing(true)
|
||||
|
||||
try {
|
||||
const agent = new Agent(null, {service: serviceUrl})
|
||||
await agent.com.atproto.server.requestPasswordReset({email})
|
||||
/*
|
||||
* Pre-auth request against a user-chosen host, so it goes through a
|
||||
* one-off service client rather than a session-scoped one.
|
||||
*/
|
||||
const client = createServiceClient(serviceUrl)
|
||||
await client.call(com.atproto.server.requestPasswordReset, {email})
|
||||
onEmailSent()
|
||||
} catch (err) {
|
||||
logger.warn('Failed to request password reset', {error: err})
|
||||
|
||||
@@ -2,10 +2,10 @@ import {useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {createServiceClient} from '#/lib/lexClient'
|
||||
import {cleanError, isNetworkError} from '#/lib/strings/errors'
|
||||
import {checkAndFormatResetCode} from '#/lib/strings/password'
|
||||
import {logger} from '#/logger'
|
||||
import {Agent} from '#/state/session/agent'
|
||||
import {atoms as a, web} from '#/alf'
|
||||
import {Admonition} from '#/components/Admonition'
|
||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||
@@ -16,6 +16,7 @@ import {Loader} from '#/components/Loader'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_WEB} from '#/env'
|
||||
import {com} from '#/lexicons'
|
||||
import {FormContainer} from './FormContainer'
|
||||
|
||||
export const SetNewPasswordForm = ({
|
||||
@@ -61,8 +62,12 @@ export const SetNewPasswordForm = ({
|
||||
setIsProcessing(true)
|
||||
|
||||
try {
|
||||
const agent = new Agent(null, {service: serviceUrl})
|
||||
await agent.com.atproto.server.resetPassword({
|
||||
/*
|
||||
* Pre-auth request against a user-chosen host, so it goes through a
|
||||
* one-off service client rather than a session-scoped one.
|
||||
*/
|
||||
const client = createServiceClient(serviceUrl)
|
||||
await client.call(com.atproto.server.resetPassword, {
|
||||
token: formattedCode,
|
||||
password,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user