Automatically resolve hosting provider from handle (#11053)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
import {useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
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'
|
||||
import {FormError} from '#/components/forms/FormError'
|
||||
import * as TextField from '#/components/forms/TextField'
|
||||
import {Lock_Stroke2_Corner0_Rounded as Lock} from '#/components/icons/Lock'
|
||||
import {Ticket_Stroke2_Corner0_Rounded as Ticket} from '#/components/icons/Ticket'
|
||||
@@ -33,7 +31,7 @@ export const SetNewPasswordForm = ({
|
||||
onPressBack: () => void
|
||||
onPasswordSet: () => void
|
||||
}) => {
|
||||
const {_} = useLingui()
|
||||
const {t: l} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
|
||||
const [isProcessing, setIsProcessing] = useState<boolean>(false)
|
||||
@@ -47,9 +45,7 @@ export const SetNewPasswordForm = ({
|
||||
|
||||
if (!formattedCode) {
|
||||
setError(
|
||||
_(
|
||||
msg`You have entered an invalid code. It should look like XXXXX-XXXXX.`,
|
||||
),
|
||||
l`You have entered an invalid code. It should look like XXXXX-XXXXX.`,
|
||||
)
|
||||
ax.metric('signin:passwordResetFailure', {})
|
||||
return
|
||||
@@ -57,7 +53,7 @@ export const SetNewPasswordForm = ({
|
||||
|
||||
// TODO Better password strength check
|
||||
if (!password) {
|
||||
setError(_(msg`Please enter a password.`))
|
||||
setError(l`Please enter a password.`)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -72,19 +68,16 @@ export const SetNewPasswordForm = ({
|
||||
})
|
||||
onPasswordSet()
|
||||
ax.metric('signin:passwordResetSuccess', {})
|
||||
} catch (e: any) {
|
||||
const errMsg = e.toString()
|
||||
logger.warn('Failed to set new password', {error: e})
|
||||
} catch (err) {
|
||||
logger.warn('Failed to set new password', {error: err})
|
||||
ax.metric('signin:passwordResetFailure', {})
|
||||
setIsProcessing(false)
|
||||
if (isNetworkError(e)) {
|
||||
if (isNetworkError(err)) {
|
||||
setError(
|
||||
_(
|
||||
msg`Unable to contact your service. Please check your Internet connection.`,
|
||||
),
|
||||
l`Unable to contact your service. Please check your Internet connection.`,
|
||||
)
|
||||
} else {
|
||||
setError(cleanError(errMsg))
|
||||
setError(cleanError(err))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -93,9 +86,7 @@ export const SetNewPasswordForm = ({
|
||||
const formattedCode = checkAndFormatResetCode(resetCode)
|
||||
if (!formattedCode) {
|
||||
setError(
|
||||
_(
|
||||
msg`You have entered an invalid code. It should look like XXXXX-XXXXX.`,
|
||||
),
|
||||
l`You have entered an invalid code. It should look like XXXXX-XXXXX.`,
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -112,7 +103,6 @@ export const SetNewPasswordForm = ({
|
||||
then enter your new password.
|
||||
</Trans>
|
||||
</Text>
|
||||
|
||||
<View>
|
||||
<TextField.LabelText>
|
||||
<Trans>Reset code</Trans>
|
||||
@@ -121,7 +111,7 @@ export const SetNewPasswordForm = ({
|
||||
<TextField.Icon icon={Ticket} />
|
||||
<TextField.Input
|
||||
testID="resetCodeInput"
|
||||
label={_(msg`Looks like XXXXX-XXXXX`)}
|
||||
label={l`Looks like XXXXX-XXXXX`}
|
||||
autoCapitalize="none"
|
||||
autoFocus={true}
|
||||
autoCorrect={false}
|
||||
@@ -131,13 +121,10 @@ export const SetNewPasswordForm = ({
|
||||
onFocus={() => setError('')}
|
||||
onBlur={onBlur}
|
||||
editable={!isProcessing}
|
||||
accessibilityHint={_(
|
||||
msg`Input code sent to your email for password reset`,
|
||||
)}
|
||||
accessibilityHint={l`Input code sent to your email for password reset`}
|
||||
/>
|
||||
</TextField.Root>
|
||||
</View>
|
||||
|
||||
<View>
|
||||
<TextField.LabelText>
|
||||
<Trans>New password</Trans>
|
||||
@@ -146,7 +133,7 @@ export const SetNewPasswordForm = ({
|
||||
<TextField.Icon icon={Lock} />
|
||||
<TextField.Input
|
||||
testID="newPasswordInput"
|
||||
label={_(msg`Enter a password`)}
|
||||
label={l`Enter a password`}
|
||||
autoCapitalize="none"
|
||||
autoCorrect={false}
|
||||
returnKeyType="done"
|
||||
@@ -156,20 +143,18 @@ export const SetNewPasswordForm = ({
|
||||
clearButtonMode="while-editing"
|
||||
value={password}
|
||||
onChangeText={setPassword}
|
||||
onSubmitEditing={onPressNext}
|
||||
onSubmitEditing={() => void onPressNext()}
|
||||
editable={!isProcessing}
|
||||
accessibilityHint={_(msg`Input new password`)}
|
||||
accessibilityHint={l`Input new password`}
|
||||
/>
|
||||
</TextField.Root>
|
||||
</View>
|
||||
|
||||
<FormError error={error} />
|
||||
|
||||
{error && <Admonition type="error">{error}</Admonition>}
|
||||
<View style={[web([a.flex_row, a.align_center]), a.pt_lg]}>
|
||||
{IS_WEB && (
|
||||
<>
|
||||
<Button
|
||||
label={_(msg`Back`)}
|
||||
label={l`Back`}
|
||||
variant="solid"
|
||||
color="secondary"
|
||||
size="large"
|
||||
@@ -183,10 +168,10 @@ export const SetNewPasswordForm = ({
|
||||
)}
|
||||
|
||||
<Button
|
||||
label={_(msg`Next`)}
|
||||
label={l`Next`}
|
||||
color="primary"
|
||||
size="large"
|
||||
onPress={onPressNext}
|
||||
onPress={() => void onPressNext()}
|
||||
disabled={isProcessing}>
|
||||
<ButtonText>
|
||||
<Trans>Next</Trans>
|
||||
|
||||
Reference in New Issue
Block a user