[AAv2] Improve minimum age handling (#9650)
* Improve miminum age handling * Update api sdk * Fix bad import
This commit is contained in:
+1
-1
@@ -73,7 +73,7 @@
|
|||||||
"icons:optimize": "svgo -f ./assets/icons"
|
"icons:optimize": "svgo -f ./assets/icons"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@atproto/api": "^0.18.8",
|
"@atproto/api": "^0.18.11",
|
||||||
"@bitdrift/react-native": "^0.6.8",
|
"@bitdrift/react-native": "^0.6.8",
|
||||||
"@braintree/sanitize-url": "^6.0.2",
|
"@braintree/sanitize-url": "^6.0.2",
|
||||||
"@bsky.app/alf": "^0.1.6",
|
"@bsky.app/alf": "^0.1.6",
|
||||||
|
|||||||
@@ -177,10 +177,19 @@ export function NoAccessScreen() {
|
|||||||
</Trans>
|
</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
{!aa.flags.isOverRegionMinAccessAge && (
|
||||||
|
<Text style={[textStyles]}>
|
||||||
|
<Trans>
|
||||||
|
Unfortunately, your declared age indicates that you
|
||||||
|
are not old enough to access Bluesky in your region.
|
||||||
|
</Trans>
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
|
||||||
{!isBlocked && birthdateUpdateText}
|
{!isBlocked && birthdateUpdateText}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<AccessSection />
|
{aa.flags.isOverRegionMinAccessAge && <AccessSection />}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<View style={[a.gap_lg]}>
|
<View style={[a.gap_lg]}>
|
||||||
|
|||||||
@@ -12,23 +12,26 @@ export const enabled = (IS_DEV && false) || IS_E2E
|
|||||||
|
|
||||||
export const geolocation: Geolocation | undefined = enabled
|
export const geolocation: Geolocation | undefined = enabled
|
||||||
? {
|
? {
|
||||||
countryCode: 'AA',
|
countryCode: 'BB',
|
||||||
regionCode: undefined,
|
regionCode: undefined,
|
||||||
}
|
}
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
export const deviceGeolocation: Geolocation | undefined = enabled
|
const deviceGeolocationEnabled = false
|
||||||
? {
|
export const deviceGeolocation: Geolocation | undefined =
|
||||||
countryCode: 'AA',
|
enabled && deviceGeolocationEnabled
|
||||||
regionCode: undefined,
|
? {
|
||||||
}
|
countryCode: 'AA',
|
||||||
: undefined
|
regionCode: undefined,
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
|
||||||
export const config: AppBskyAgeassuranceDefs.Config = {
|
export const config: AppBskyAgeassuranceDefs.Config = {
|
||||||
regions: [
|
regions: [
|
||||||
{
|
{
|
||||||
countryCode: 'AA',
|
countryCode: 'AA',
|
||||||
regionCode: undefined,
|
regionCode: undefined,
|
||||||
|
minAccessAge: 13,
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
$type: ids.Default,
|
$type: ids.Default,
|
||||||
@@ -36,6 +39,17 @@ export const config: AppBskyAgeassuranceDefs.Config = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
countryCode: 'BB',
|
||||||
|
regionCode: undefined,
|
||||||
|
minAccessAge: 16,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
$type: ids.Default,
|
||||||
|
access: 'none',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,11 @@ import {
|
|||||||
type AgeAssuranceState,
|
type AgeAssuranceState,
|
||||||
AgeAssuranceStatus,
|
AgeAssuranceStatus,
|
||||||
} from '#/ageAssurance/types'
|
} from '#/ageAssurance/types'
|
||||||
import {isUserUnderAdultAge} from '#/ageAssurance/util'
|
import {
|
||||||
|
isUnderAge,
|
||||||
|
MIN_ACCESS_AGE,
|
||||||
|
useAgeAssuranceRegionConfigWithFallback,
|
||||||
|
} from '#/ageAssurance/util'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
prefetchConfig as prefetchAgeAssuranceConfig,
|
prefetchConfig as prefetchAgeAssuranceConfig,
|
||||||
@@ -24,6 +28,7 @@ export {
|
|||||||
usePatchServerState as usePatchAgeAssuranceServerState,
|
usePatchServerState as usePatchAgeAssuranceServerState,
|
||||||
} from '#/ageAssurance/data'
|
} from '#/ageAssurance/data'
|
||||||
export {logger} from '#/ageAssurance/logger'
|
export {logger} from '#/ageAssurance/logger'
|
||||||
|
export {MIN_ACCESS_AGE} from '#/ageAssurance/util'
|
||||||
|
|
||||||
const AgeAssuranceStateContext = createContext<{
|
const AgeAssuranceStateContext = createContext<{
|
||||||
Access: typeof AgeAssuranceAccess
|
Access: typeof AgeAssuranceAccess
|
||||||
@@ -32,6 +37,8 @@ const AgeAssuranceStateContext = createContext<{
|
|||||||
flags: {
|
flags: {
|
||||||
adultContentDisabled: boolean
|
adultContentDisabled: boolean
|
||||||
chatDisabled: boolean
|
chatDisabled: boolean
|
||||||
|
isOverRegionMinAccessAge: boolean
|
||||||
|
isOverAppMinAccessAge: boolean
|
||||||
}
|
}
|
||||||
}>({
|
}>({
|
||||||
Access: AgeAssuranceAccess,
|
Access: AgeAssuranceAccess,
|
||||||
@@ -44,6 +51,8 @@ const AgeAssuranceStateContext = createContext<{
|
|||||||
flags: {
|
flags: {
|
||||||
adultContentDisabled: false,
|
adultContentDisabled: false,
|
||||||
chatDisabled: false,
|
chatDisabled: false,
|
||||||
|
isOverRegionMinAccessAge: false,
|
||||||
|
isOverAppMinAccessAge: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -69,6 +78,7 @@ export function Provider({children}: {children: React.ReactNode}) {
|
|||||||
function InnerProvider({children}: {children: React.ReactNode}) {
|
function InnerProvider({children}: {children: React.ReactNode}) {
|
||||||
const state = useAgeAssuranceState()
|
const state = useAgeAssuranceState()
|
||||||
const {data} = useAgeAssuranceDataContext()
|
const {data} = useAgeAssuranceDataContext()
|
||||||
|
const config = useAgeAssuranceRegionConfigWithFallback()
|
||||||
const getAndRegisterPushToken = useGetAndRegisterPushToken()
|
const getAndRegisterPushToken = useGetAndRegisterPushToken()
|
||||||
|
|
||||||
const handleAccessUpdate = useCallback(
|
const handleAccessUpdate = useCallback(
|
||||||
@@ -89,11 +99,17 @@ function InnerProvider({children}: {children: React.ReactNode}) {
|
|||||||
<AgeAssuranceStateContext.Provider
|
<AgeAssuranceStateContext.Provider
|
||||||
value={useMemo(() => {
|
value={useMemo(() => {
|
||||||
const chatDisabled = state.access !== AgeAssuranceAccess.Full
|
const chatDisabled = state.access !== AgeAssuranceAccess.Full
|
||||||
const isUnderage = data?.birthdate
|
const isUnderAdultAge = data?.birthdate
|
||||||
? isUserUnderAdultAge(data.birthdate)
|
? isUnderAge(data.birthdate, 18)
|
||||||
: true
|
: true
|
||||||
|
const isOverRegionMinAccessAge = data?.birthdate
|
||||||
|
? !isUnderAge(data.birthdate, config.minAccessAge)
|
||||||
|
: false
|
||||||
|
const isOverAppMinAccessAge = data?.birthdate
|
||||||
|
? !isUnderAge(data.birthdate, MIN_ACCESS_AGE)
|
||||||
|
: false
|
||||||
const adultContentDisabled =
|
const adultContentDisabled =
|
||||||
state.access !== AgeAssuranceAccess.Full || isUnderage
|
state.access !== AgeAssuranceAccess.Full || isUnderAdultAge
|
||||||
return {
|
return {
|
||||||
Access: AgeAssuranceAccess,
|
Access: AgeAssuranceAccess,
|
||||||
Status: AgeAssuranceStatus,
|
Status: AgeAssuranceStatus,
|
||||||
@@ -101,9 +117,11 @@ function InnerProvider({children}: {children: React.ReactNode}) {
|
|||||||
flags: {
|
flags: {
|
||||||
adultContentDisabled,
|
adultContentDisabled,
|
||||||
chatDisabled,
|
chatDisabled,
|
||||||
|
isOverRegionMinAccessAge,
|
||||||
|
isOverAppMinAccessAge,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}, [state, data])}>
|
}, [state, data, config])}>
|
||||||
{children}
|
{children}
|
||||||
</AgeAssuranceStateContext.Provider>
|
</AgeAssuranceStateContext.Provider>
|
||||||
)
|
)
|
||||||
|
|||||||
+30
-26
@@ -12,7 +12,23 @@ import {useAgeAssuranceDataContext} from '#/ageAssurance/data'
|
|||||||
import {AgeAssuranceAccess} from '#/ageAssurance/types'
|
import {AgeAssuranceAccess} from '#/ageAssurance/types'
|
||||||
import {type Geolocation, useGeolocation} from '#/geolocation'
|
import {type Geolocation, useGeolocation} from '#/geolocation'
|
||||||
|
|
||||||
const DEFAULT_MIN_AGE = 13
|
export const MIN_ACCESS_AGE = 13
|
||||||
|
const FALLBACK_REGION_CONFIG: AppBskyAgeassuranceDefs.ConfigRegion = {
|
||||||
|
countryCode: '*',
|
||||||
|
regionCode: undefined,
|
||||||
|
minAccessAge: MIN_ACCESS_AGE,
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
$type: ids.IfDeclaredOverAge,
|
||||||
|
age: MIN_ACCESS_AGE,
|
||||||
|
access: AgeAssuranceAccess.Full,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$type: ids.Default,
|
||||||
|
access: AgeAssuranceAccess.None,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get age assurance region config based on geolocation, with fallback to
|
* Get age assurance region config based on geolocation, with fallback to
|
||||||
@@ -30,23 +46,7 @@ export function getAgeAssuranceRegionConfigWithFallback(
|
|||||||
regionCode: geolocation.regionCode,
|
regionCode: geolocation.regionCode,
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return region || FALLBACK_REGION_CONFIG
|
||||||
region || {
|
|
||||||
countryCode: '*',
|
|
||||||
regionCode: undefined,
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
$type: ids.IfDeclaredOverAge,
|
|
||||||
age: DEFAULT_MIN_AGE,
|
|
||||||
access: AgeAssuranceAccess.Full,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
$type: ids.Default,
|
|
||||||
access: AgeAssuranceAccess.None,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -67,6 +67,14 @@ export function useAgeAssuranceRegionConfig() {
|
|||||||
}, [config, geolocation])
|
}, [config, geolocation])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook to get the age assurance region config based on current geolocation.
|
||||||
|
* Falls back to our app defaults if no region config is found.
|
||||||
|
*/
|
||||||
|
export function useAgeAssuranceRegionConfigWithFallback() {
|
||||||
|
return useAgeAssuranceRegionConfig() || FALLBACK_REGION_CONFIG
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some users may have erroneously set their birth date to the current date
|
* Some users may have erroneously set their birth date to the current date
|
||||||
* if one wasn't set on their account. We previously didn't do validation on
|
* if one wasn't set on their account. We previously didn't do validation on
|
||||||
@@ -78,15 +86,11 @@ export function isLegacyBirthdateBug(birthDate: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the user is under the minimum age required to use the app.
|
* Returns whether the date (converted to an age as a whole integer) is under
|
||||||
* This applies to all regions.
|
* the provided minimum age.
|
||||||
*/
|
*/
|
||||||
export function isUserUnderMinimumAge(birthDate: string) {
|
export function isUnderAge(birthDate: string, age: number) {
|
||||||
return getAge(new Date(birthDate)) < DEFAULT_MIN_AGE
|
return getAge(new Date(birthDate)) < age
|
||||||
}
|
|
||||||
|
|
||||||
export function isUserUnderAdultAge(birthDate: string) {
|
|
||||||
return getAge(new Date(birthDate)) < 18
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBirthdateStringFromAge(age: number) {
|
export function getBirthdateStringFromAge(age: number) {
|
||||||
|
|||||||
@@ -5,14 +5,20 @@ import {type Geolocation} from '#/geolocation/types'
|
|||||||
const localEnabled = false
|
const localEnabled = false
|
||||||
export const enabled = IS_DEV && (localEnabled || aaDebug.geolocation)
|
export const enabled = IS_DEV && (localEnabled || aaDebug.geolocation)
|
||||||
export const geolocation: Geolocation = aaDebug.geolocation ?? {
|
export const geolocation: Geolocation = aaDebug.geolocation ?? {
|
||||||
countryCode: 'AU',
|
countryCode: 'US',
|
||||||
regionCode: undefined,
|
regionCode: 'TX',
|
||||||
}
|
|
||||||
export const deviceGeolocation: Geolocation = aaDebug.deviceGeolocation ?? {
|
|
||||||
countryCode: 'AU',
|
|
||||||
regionCode: undefined,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deviceLocalEnabled = false
|
||||||
|
export const deviceGeolocation: Geolocation | undefined =
|
||||||
|
aaDebug.deviceGeolocation ||
|
||||||
|
(deviceLocalEnabled
|
||||||
|
? {
|
||||||
|
countryCode: 'US',
|
||||||
|
regionCode: 'TX',
|
||||||
|
}
|
||||||
|
: undefined)
|
||||||
|
|
||||||
export async function resolve<T>(data: T) {
|
export async function resolve<T>(data: T) {
|
||||||
await new Promise(y => setTimeout(y, 500)) // simulate network
|
await new Promise(y => setTimeout(y, 500)) // simulate network
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ const useForegroundPermissions = createPermissionHook({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export async function getDeviceGeolocation(): Promise<Geolocation> {
|
export async function getDeviceGeolocation(): Promise<Geolocation> {
|
||||||
if (debug.enabled) return debug.resolve(debug.deviceGeolocation)
|
if (debug.enabled && debug.deviceGeolocation)
|
||||||
|
return debug.resolve(debug.deviceGeolocation)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const geocode = await Location.getCurrentPositionAsync()
|
const geocode = await Location.getCurrentPositionAsync()
|
||||||
@@ -142,3 +143,8 @@ export function useSyncDeviceGeolocationOnStartup(
|
|||||||
})
|
})
|
||||||
}, [status, sync])
|
}, [status, sync])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useIsDeviceGeolocationGranted() {
|
||||||
|
const [status] = useForegroundPermissions()
|
||||||
|
return status?.granted === true
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,7 +12,10 @@ import {type Geolocation} from '#/geolocation/types'
|
|||||||
import {mergeGeolocations} from '#/geolocation/util'
|
import {mergeGeolocations} from '#/geolocation/util'
|
||||||
import {device, useStorage} from '#/storage'
|
import {device, useStorage} from '#/storage'
|
||||||
|
|
||||||
export {useRequestDeviceGeolocation} from '#/geolocation/device'
|
export {
|
||||||
|
useIsDeviceGeolocationGranted,
|
||||||
|
useRequestDeviceGeolocation,
|
||||||
|
} from '#/geolocation/device'
|
||||||
export {resolve} from '#/geolocation/service'
|
export {resolve} from '#/geolocation/service'
|
||||||
export * from '#/geolocation/types'
|
export * from '#/geolocation/types'
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,8 @@ import {Text} from '#/components/Typography'
|
|||||||
|
|
||||||
export const Policies = ({
|
export const Policies = ({
|
||||||
serviceDescription,
|
serviceDescription,
|
||||||
needsGuardian,
|
|
||||||
under13,
|
|
||||||
}: {
|
}: {
|
||||||
serviceDescription: ComAtprotoServerDescribeServer.OutputSchema
|
serviceDescription: ComAtprotoServerDescribeServer.OutputSchema
|
||||||
needsGuardian: boolean
|
|
||||||
under13: boolean
|
|
||||||
}) => {
|
}) => {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
@@ -91,30 +87,9 @@ export const Policies = ({
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return els ? (
|
||||||
<View style={[a.gap_sm]}>
|
<Text style={[a.leading_snug, t.atoms.text_contrast_medium]}>{els}</Text>
|
||||||
{els ? (
|
) : null
|
||||||
<Text style={[a.leading_snug, t.atoms.text_contrast_medium]}>
|
|
||||||
{els}
|
|
||||||
</Text>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
{under13 ? (
|
|
||||||
<Admonition type="error">
|
|
||||||
<Trans>
|
|
||||||
You must be 13 years of age or older to create an account.
|
|
||||||
</Trans>
|
|
||||||
</Admonition>
|
|
||||||
) : needsGuardian ? (
|
|
||||||
<Admonition type="warning">
|
|
||||||
<Trans>
|
|
||||||
If you are not yet an adult according to the laws of your country,
|
|
||||||
your parent or legal guardian must read these Terms on your behalf.
|
|
||||||
</Trans>
|
|
||||||
</Admonition>
|
|
||||||
) : undefined}
|
|
||||||
</View>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function validWebLink(url?: string): string | undefined {
|
function validWebLink(url?: string): string | undefined {
|
||||||
|
|||||||
@@ -7,9 +7,13 @@ import type tldts from 'tldts'
|
|||||||
|
|
||||||
import {isEmailMaybeInvalid} from '#/lib/strings/email'
|
import {isEmailMaybeInvalid} from '#/lib/strings/email'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {is13, is18, useSignupContext} from '#/screens/Signup/state'
|
import {isNative} from '#/platform/detection'
|
||||||
|
import {useSignupContext} from '#/screens/Signup/state'
|
||||||
import {Policies} from '#/screens/Signup/StepInfo/Policies'
|
import {Policies} from '#/screens/Signup/StepInfo/Policies'
|
||||||
import {atoms as a, native} from '#/alf'
|
import {atoms as a, native} from '#/alf'
|
||||||
|
import * as Admonition from '#/components/Admonition'
|
||||||
|
import * as Dialog from '#/components/Dialog'
|
||||||
|
import {DeviceLocationRequestDialog} from '#/components/dialogs/DeviceLocationRequestDialog'
|
||||||
import * as DateField from '#/components/forms/DateField'
|
import * as DateField from '#/components/forms/DateField'
|
||||||
import {type DateFieldRef} from '#/components/forms/DateField/types'
|
import {type DateFieldRef} from '#/components/forms/DateField/types'
|
||||||
import {FormError} from '#/components/forms/FormError'
|
import {FormError} from '#/components/forms/FormError'
|
||||||
@@ -18,8 +22,19 @@ import * as TextField from '#/components/forms/TextField'
|
|||||||
import {Envelope_Stroke2_Corner0_Rounded as Envelope} from '#/components/icons/Envelope'
|
import {Envelope_Stroke2_Corner0_Rounded as Envelope} from '#/components/icons/Envelope'
|
||||||
import {Lock_Stroke2_Corner0_Rounded as Lock} from '#/components/icons/Lock'
|
import {Lock_Stroke2_Corner0_Rounded as Lock} from '#/components/icons/Lock'
|
||||||
import {Ticket_Stroke2_Corner0_Rounded as Ticket} from '#/components/icons/Ticket'
|
import {Ticket_Stroke2_Corner0_Rounded as Ticket} from '#/components/icons/Ticket'
|
||||||
|
import {createStaticClick, SimpleInlineLinkText} from '#/components/Link'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {usePreemptivelyCompleteActivePolicyUpdate} from '#/components/PolicyUpdateOverlay/usePreemptivelyCompleteActivePolicyUpdate'
|
import {usePreemptivelyCompleteActivePolicyUpdate} from '#/components/PolicyUpdateOverlay/usePreemptivelyCompleteActivePolicyUpdate'
|
||||||
|
import * as Toast from '#/components/Toast'
|
||||||
|
import {
|
||||||
|
isUnderAge,
|
||||||
|
MIN_ACCESS_AGE,
|
||||||
|
useAgeAssuranceRegionConfigWithFallback,
|
||||||
|
} from '#/ageAssurance/util'
|
||||||
|
import {
|
||||||
|
useDeviceGeolocationApi,
|
||||||
|
useIsDeviceGeolocationGranted,
|
||||||
|
} from '#/geolocation'
|
||||||
import {BackNextButtons} from '../BackNextButtons'
|
import {BackNextButtons} from '../BackNextButtons'
|
||||||
|
|
||||||
function sanitizeDate(date: Date): Date {
|
function sanitizeDate(date: Date): Date {
|
||||||
@@ -57,6 +72,20 @@ export function StepInfo({
|
|||||||
const passwordInputRef = useRef<TextInput>(null)
|
const passwordInputRef = useRef<TextInput>(null)
|
||||||
const birthdateInputRef = useRef<DateFieldRef>(null)
|
const birthdateInputRef = useRef<DateFieldRef>(null)
|
||||||
|
|
||||||
|
const aaRegionConfig = useAgeAssuranceRegionConfigWithFallback()
|
||||||
|
const {setDeviceGeolocation} = useDeviceGeolocationApi()
|
||||||
|
const locationControl = Dialog.useDialogControl()
|
||||||
|
const isOverRegionMinAccessAge = state.dateOfBirth
|
||||||
|
? !isUnderAge(state.dateOfBirth.toISOString(), aaRegionConfig.minAccessAge)
|
||||||
|
: true
|
||||||
|
const isOverAppMinAccessAge = state.dateOfBirth
|
||||||
|
? !isUnderAge(state.dateOfBirth.toISOString(), MIN_ACCESS_AGE)
|
||||||
|
: true
|
||||||
|
const isOverMinAdultAge = state.dateOfBirth
|
||||||
|
? !isUnderAge(state.dateOfBirth.toISOString(), 18)
|
||||||
|
: true
|
||||||
|
const isDeviceGeolocationGranted = useIsDeviceGeolocationGranted()
|
||||||
|
|
||||||
const [hasWarnedEmail, setHasWarnedEmail] = React.useState<boolean>(false)
|
const [hasWarnedEmail, setHasWarnedEmail] = React.useState<boolean>(false)
|
||||||
|
|
||||||
const tldtsRef = React.useRef<typeof tldts>(undefined)
|
const tldtsRef = React.useRef<typeof tldts>(undefined)
|
||||||
@@ -76,7 +105,7 @@ export function StepInfo({
|
|||||||
const emailChanged = prevEmailValueRef.current !== email
|
const emailChanged = prevEmailValueRef.current !== email
|
||||||
const password = passwordValueRef.current
|
const password = passwordValueRef.current
|
||||||
|
|
||||||
if (!is13(state.dateOfBirth)) {
|
if (!isOverRegionMinAccessAge) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,16 +303,79 @@ export function StepInfo({
|
|||||||
maximumDate={new Date()}
|
maximumDate={new Date()}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Policies
|
|
||||||
serviceDescription={state.serviceDescription}
|
<View style={[a.gap_sm]}>
|
||||||
needsGuardian={!is18(state.dateOfBirth)}
|
<Policies serviceDescription={state.serviceDescription} />
|
||||||
under13={!is13(state.dateOfBirth)}
|
|
||||||
/>
|
{!isOverRegionMinAccessAge || !isOverAppMinAccessAge ? (
|
||||||
|
<Admonition.Outer type="error">
|
||||||
|
<Admonition.Row>
|
||||||
|
<Admonition.Icon />
|
||||||
|
<Admonition.Content>
|
||||||
|
<Admonition.Text>
|
||||||
|
{!isOverAppMinAccessAge ? (
|
||||||
|
<Trans>
|
||||||
|
You must be {MIN_ACCESS_AGE} years of age or older
|
||||||
|
to create an account.
|
||||||
|
</Trans>
|
||||||
|
) : (
|
||||||
|
<Trans>
|
||||||
|
You must be {aaRegionConfig.minAccessAge} years of
|
||||||
|
age or older to create an account in your region.
|
||||||
|
</Trans>
|
||||||
|
)}
|
||||||
|
</Admonition.Text>
|
||||||
|
{isNative &&
|
||||||
|
!isDeviceGeolocationGranted &&
|
||||||
|
isOverAppMinAccessAge && (
|
||||||
|
<Admonition.Text>
|
||||||
|
<Trans>
|
||||||
|
Have we got your location wrong?{' '}
|
||||||
|
<SimpleInlineLinkText
|
||||||
|
label={_(
|
||||||
|
msg`Tap here to confirm your location with GPS.`,
|
||||||
|
)}
|
||||||
|
{...createStaticClick(() => {
|
||||||
|
locationControl.open()
|
||||||
|
})}>
|
||||||
|
Tap here to confirm your location with GPS.
|
||||||
|
</SimpleInlineLinkText>
|
||||||
|
</Trans>
|
||||||
|
</Admonition.Text>
|
||||||
|
)}
|
||||||
|
</Admonition.Content>
|
||||||
|
</Admonition.Row>
|
||||||
|
</Admonition.Outer>
|
||||||
|
) : !isOverMinAdultAge ? (
|
||||||
|
<Admonition.Admonition type="warning">
|
||||||
|
<Trans>
|
||||||
|
If you are not yet an adult according to the laws of your
|
||||||
|
country, your parent or legal guardian must read these Terms
|
||||||
|
on your behalf.
|
||||||
|
</Trans>
|
||||||
|
</Admonition.Admonition>
|
||||||
|
) : undefined}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{isNative && (
|
||||||
|
<DeviceLocationRequestDialog
|
||||||
|
control={locationControl}
|
||||||
|
onLocationAcquired={props => {
|
||||||
|
props.closeDialog(() => {
|
||||||
|
// set this after close!
|
||||||
|
setDeviceGeolocation(props.geolocation)
|
||||||
|
Toast.show(_(msg`Your location has been updated.`), {
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
</View>
|
</View>
|
||||||
<BackNextButtons
|
<BackNextButtons
|
||||||
hideNext={!is13(state.dateOfBirth)}
|
hideNext={!isOverRegionMinAccessAge}
|
||||||
showRetry={isServerError}
|
showRetry={isServerError}
|
||||||
isLoading={state.isLoading}
|
isLoading={state.isLoading}
|
||||||
onBackPress={onPressBack}
|
onBackPress={onPressBack}
|
||||||
|
|||||||
@@ -82,6 +82,20 @@
|
|||||||
"@atproto/xrpc" "^0.7.6"
|
"@atproto/xrpc" "^0.7.6"
|
||||||
"@atproto/xrpc-server" "^0.10.0"
|
"@atproto/xrpc-server" "^0.10.0"
|
||||||
|
|
||||||
|
"@atproto/api@^0.18.11":
|
||||||
|
version "0.18.11"
|
||||||
|
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.18.11.tgz#38b8bacecaae4c24bc29bd98b34f270d8be675b3"
|
||||||
|
integrity sha512-YhgyL4rOBFOIs+e/8s5S+EjwM3T5q65IKh30ZoIrWcQS/2uteiIzg1xB+iXmexZq4Cwug0NLfRUJDViDK/ut0w==
|
||||||
|
dependencies:
|
||||||
|
"@atproto/common-web" "^0.4.10"
|
||||||
|
"@atproto/lexicon" "^0.6.0"
|
||||||
|
"@atproto/syntax" "^0.4.2"
|
||||||
|
"@atproto/xrpc" "^0.7.7"
|
||||||
|
await-lock "^2.2.2"
|
||||||
|
multiformats "^9.9.0"
|
||||||
|
tlds "^1.234.0"
|
||||||
|
zod "^3.23.8"
|
||||||
|
|
||||||
"@atproto/api@^0.18.5", "@atproto/api@^0.18.7":
|
"@atproto/api@^0.18.5", "@atproto/api@^0.18.7":
|
||||||
version "0.18.7"
|
version "0.18.7"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.18.7.tgz#3175ec8f1909ddcae488183a2180de234e7acce4"
|
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.18.7.tgz#3175ec8f1909ddcae488183a2180de234e7acce4"
|
||||||
@@ -110,20 +124,6 @@
|
|||||||
tlds "^1.234.0"
|
tlds "^1.234.0"
|
||||||
zod "^3.23.8"
|
zod "^3.23.8"
|
||||||
|
|
||||||
"@atproto/api@^0.18.8":
|
|
||||||
version "0.18.8"
|
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.18.8.tgz#6df69731005413d8507345829a12abeda787c32d"
|
|
||||||
integrity sha512-Qo3sGd1N5hdHTaEWUBgptvPkULt2SXnMcWRhveSyctSd/IQwTMyaIH6E62A1SU+8xBSN5QLpoUJNE7iSrYM2Zg==
|
|
||||||
dependencies:
|
|
||||||
"@atproto/common-web" "^0.4.7"
|
|
||||||
"@atproto/lexicon" "^0.6.0"
|
|
||||||
"@atproto/syntax" "^0.4.2"
|
|
||||||
"@atproto/xrpc" "^0.7.7"
|
|
||||||
await-lock "^2.2.2"
|
|
||||||
multiformats "^9.9.0"
|
|
||||||
tlds "^1.234.0"
|
|
||||||
zod "^3.23.8"
|
|
||||||
|
|
||||||
"@atproto/aws@^0.2.31":
|
"@atproto/aws@^0.2.31":
|
||||||
version "0.2.31"
|
version "0.2.31"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/aws/-/aws-0.2.31.tgz#e46d7db34ee57c4f9817269f1e73a7eddba2b9b8"
|
resolved "https://registry.yarnpkg.com/@atproto/aws/-/aws-0.2.31.tgz#e46d7db34ee57c4f9817269f1e73a7eddba2b9b8"
|
||||||
@@ -208,6 +208,15 @@
|
|||||||
pino-http "^8.2.1"
|
pino-http "^8.2.1"
|
||||||
typed-emitter "^2.1.0"
|
typed-emitter "^2.1.0"
|
||||||
|
|
||||||
|
"@atproto/common-web@^0.4.10":
|
||||||
|
version "0.4.10"
|
||||||
|
resolved "https://registry.yarnpkg.com/@atproto/common-web/-/common-web-0.4.10.tgz#3d29df4dc3ea8f5c149161209f55e146f27867c1"
|
||||||
|
integrity sha512-TLDZSgSKzT8ZgOrBrTGK87J1CXve9TEuY6NVVUBRkOMzRRtQzpFb9/ih5WVS/hnaWVvE30CfuyaetRoma+WKNw==
|
||||||
|
dependencies:
|
||||||
|
"@atproto/lex-data" "0.0.6"
|
||||||
|
"@atproto/lex-json" "0.0.6"
|
||||||
|
zod "^3.23.8"
|
||||||
|
|
||||||
"@atproto/common-web@^0.4.4", "@atproto/common-web@^0.4.6":
|
"@atproto/common-web@^0.4.4", "@atproto/common-web@^0.4.6":
|
||||||
version "0.4.6"
|
version "0.4.6"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/common-web/-/common-web-0.4.6.tgz#e32395d44d812610fd99f718b8644308b828d68b"
|
resolved "https://registry.yarnpkg.com/@atproto/common-web/-/common-web-0.4.6.tgz#e32395d44d812610fd99f718b8644308b828d68b"
|
||||||
@@ -406,6 +415,17 @@
|
|||||||
uint8arrays "3.0.0"
|
uint8arrays "3.0.0"
|
||||||
unicode-segmenter "^0.14.0"
|
unicode-segmenter "^0.14.0"
|
||||||
|
|
||||||
|
"@atproto/lex-data@0.0.6":
|
||||||
|
version "0.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/@atproto/lex-data/-/lex-data-0.0.6.tgz#280d05ec9579ab091dc4a8b696ebbeddcb8ee37d"
|
||||||
|
integrity sha512-MBNB4ghRJQzuXK1zlUPljpPbQcF1LZ5dzxy274KqPt4p3uPuRw0mHjgcCoWzRUNBQC685WMQR4IN9DHtsnG57A==
|
||||||
|
dependencies:
|
||||||
|
"@atproto/syntax" "0.4.2"
|
||||||
|
multiformats "^9.9.0"
|
||||||
|
tslib "^2.8.1"
|
||||||
|
uint8arrays "3.0.0"
|
||||||
|
unicode-segmenter "^0.14.0"
|
||||||
|
|
||||||
"@atproto/lex-document@0.0.5":
|
"@atproto/lex-document@0.0.5":
|
||||||
version "0.0.5"
|
version "0.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/lex-document/-/lex-document-0.0.5.tgz#8d4851b351149ba673c1de9c1898c3c9ebd8b4b3"
|
resolved "https://registry.yarnpkg.com/@atproto/lex-document/-/lex-document-0.0.5.tgz#8d4851b351149ba673c1de9c1898c3c9ebd8b4b3"
|
||||||
@@ -431,6 +451,14 @@
|
|||||||
"@atproto/lex-data" "0.0.3"
|
"@atproto/lex-data" "0.0.3"
|
||||||
tslib "^2.8.1"
|
tslib "^2.8.1"
|
||||||
|
|
||||||
|
"@atproto/lex-json@0.0.6":
|
||||||
|
version "0.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/@atproto/lex-json/-/lex-json-0.0.6.tgz#50618efb1cc11708b3897de14dcd3bd9c06e064d"
|
||||||
|
integrity sha512-EILnN5cditPvf+PCNjXt7reMuzjugxAL1fpSzmzJbEMGMUwxOf5pPWxRsaA/M3Boip4NQZ+6DVrPOGUMlnqceg==
|
||||||
|
dependencies:
|
||||||
|
"@atproto/lex-data" "0.0.6"
|
||||||
|
tslib "^2.8.1"
|
||||||
|
|
||||||
"@atproto/lex-resolver@0.0.5":
|
"@atproto/lex-resolver@0.0.5":
|
||||||
version "0.0.5"
|
version "0.0.5"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/lex-resolver/-/lex-resolver-0.0.5.tgz#9d0645c43423cb99b491ca8e658770395d2cd630"
|
resolved "https://registry.yarnpkg.com/@atproto/lex-resolver/-/lex-resolver-0.0.5.tgz#9d0645c43423cb99b491ca8e658770395d2cd630"
|
||||||
|
|||||||
Reference in New Issue
Block a user