Disambiguation of the deactivation

This commit is contained in:
Eric Bailey
2024-05-29 18:13:51 -05:00
parent 4d39ef2e19
commit 1b0cdf1b90
6 changed files with 15 additions and 14 deletions
@@ -6,7 +6,7 @@ import {useLingui} from '@lingui/react'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
import {isSessionDeactivated, useAgent, useSessionApi} from '#/state/session' import {isSignupQueued, useAgent, useSessionApi} from '#/state/session'
import {useOnboardingDispatch} from '#/state/shell' import {useOnboardingDispatch} from '#/state/shell'
import {ScrollView} from '#/view/com/util/Views' import {ScrollView} from '#/view/com/util/Views'
import {Logo} from '#/view/icons/Logo' import {Logo} from '#/view/icons/Logo'
@@ -17,7 +17,7 @@ import {P, Text} from '#/components/Typography'
const COL_WIDTH = 400 const COL_WIDTH = 400
export function Deactivated() { export function SignupQueued() {
const {_} = useLingui() const {_} = useLingui()
const t = useTheme() const t = useTheme()
const insets = useSafeAreaInsets() const insets = useSafeAreaInsets()
@@ -41,7 +41,7 @@ export function Deactivated() {
if (res.data.activated) { if (res.data.activated) {
// ready to go, exchange the access token for a usable one and kick off onboarding // ready to go, exchange the access token for a usable one and kick off onboarding
await agent.refreshSession() await agent.refreshSession()
if (!isSessionDeactivated(agent.session?.accessJwt)) { if (!isSignupQueued(agent.session?.accessJwt)) {
onboardingDispatch({type: 'start'}) onboardingDispatch({type: 'start'})
} }
} else { } else {
+1 -1
View File
@@ -17,7 +17,7 @@ const accountSchema = z.object({
emailAuthFactor: z.boolean().optional(), emailAuthFactor: z.boolean().optional(),
refreshJwt: z.string().optional(), // optional because it can expire refreshJwt: z.string().optional(), // optional because it can expire
accessJwt: z.string().optional(), // optional because it can expire accessJwt: z.string().optional(), // optional because it can expire
deactivated: z.boolean().optional(), signupQueued: z.boolean().optional(),
pdsUrl: z.string().optional(), pdsUrl: z.string().optional(),
}) })
export type PersistedAccount = z.infer<typeof accountSchema> export type PersistedAccount = z.infer<typeof accountSchema>
+4 -4
View File
@@ -16,7 +16,7 @@ import {
configureModerationForGuest, configureModerationForGuest,
} from './moderation' } from './moderation'
import {SessionAccount} from './types' import {SessionAccount} from './types'
import {isSessionDeactivated, isSessionExpired} from './util' import {isSessionExpired, isSignupQueued} from './util'
export function createPublicAgent() { export function createPublicAgent() {
configureModerationForGuest() // Side effect but only relevant for tests configureModerationForGuest() // Side effect but only relevant for tests
@@ -51,7 +51,7 @@ export async function createAgentAndResume(
await networkRetry(1, () => agent.resumeSession(prevSession)) await networkRetry(1, () => agent.resumeSession(prevSession))
} else { } else {
agent.session = prevSession agent.session = prevSession
if (!storedAccount.deactivated) { if (!storedAccount.signupQueued) {
// Intentionally not awaited to unblock the UI: // Intentionally not awaited to unblock the UI:
networkRetry(3, () => agent.resumeSession(prevSession)).catch( networkRetry(3, () => agent.resumeSession(prevSession)).catch(
(e: any) => { (e: any) => {
@@ -135,7 +135,7 @@ export async function createAgentAndCreateAccount(
const account = agentToSessionAccountOrThrow(agent) const account = agentToSessionAccountOrThrow(agent)
const gates = tryFetchGates(account.did, 'prefer-fresh-gates') const gates = tryFetchGates(account.did, 'prefer-fresh-gates')
const moderation = configureModerationForAccount(agent, account) const moderation = configureModerationForAccount(agent, account)
if (!account.deactivated) { if (!account.signupQueued) {
/*dont await*/ agent.upsertProfile(_existing => { /*dont await*/ agent.upsertProfile(_existing => {
return { return {
displayName: '', displayName: '',
@@ -234,7 +234,7 @@ export function agentToSessionAccount(
emailAuthFactor: agent.session.emailAuthFactor || false, emailAuthFactor: agent.session.emailAuthFactor || false,
refreshJwt: agent.session.refreshJwt, refreshJwt: agent.session.refreshJwt,
accessJwt: agent.session.accessJwt, accessJwt: agent.session.accessJwt,
deactivated: isSessionDeactivated(agent.session.accessJwt), signupQueued: isSignupQueued(agent.session.accessJwt),
pdsUrl: agent.pdsUrl?.toString(), pdsUrl: agent.pdsUrl?.toString(),
} }
} }
+1 -1
View File
@@ -17,7 +17,7 @@ import {
} from './agent' } from './agent'
import {getInitialState, reducer} from './reducer' import {getInitialState, reducer} from './reducer'
export {isSessionDeactivated} from './util' export {isSignupQueued} from './util'
export type {SessionAccount} from '#/state/session/types' export type {SessionAccount} from '#/state/session/types'
import {SessionApiContext, SessionStateContext} from '#/state/session/types' import {SessionApiContext, SessionStateContext} from '#/state/session/types'
+3 -2
View File
@@ -10,11 +10,12 @@ export function readLastActiveAccount() {
return accounts.find(a => a.did === currentAccount?.did) return accounts.find(a => a.did === currentAccount?.did)
} }
export function isSessionDeactivated(accessJwt: string | undefined) { export function isSignupQueued(accessJwt: string | undefined) {
if (accessJwt) { if (accessJwt) {
const sessData = jwtDecode(accessJwt) const sessData = jwtDecode(accessJwt)
return ( return (
hasProp(sessData, 'scope') && sessData.scope === 'com.atproto.deactivated' hasProp(sessData, 'scope') &&
sessData.scope === 'com.atproto.signupQueued'
) )
} }
return false return false
@@ -30,8 +30,8 @@ import {
useLoggedOutViewControls, useLoggedOutViewControls,
} from '#/state/shell/logged-out' } from '#/state/shell/logged-out'
import {isWeb} from 'platform/detection' import {isWeb} from 'platform/detection'
import {Deactivated} from '#/screens/Deactivated'
import {Onboarding} from '#/screens/Onboarding' import {Onboarding} from '#/screens/Onboarding'
import {SignupQueued} from '#/screens/SignupQueued'
import {LoggedOut} from '../com/auth/LoggedOut' import {LoggedOut} from '../com/auth/LoggedOut'
import {BottomBarWeb} from './bottom-bar/BottomBarWeb' import {BottomBarWeb} from './bottom-bar/BottomBarWeb'
import {DesktopLeftNav} from './desktop/LeftNav' import {DesktopLeftNav} from './desktop/LeftNav'
@@ -102,8 +102,8 @@ function NativeStackNavigator({
if ((!PWI_ENABLED || activeRouteRequiresAuth) && !hasSession) { if ((!PWI_ENABLED || activeRouteRequiresAuth) && !hasSession) {
return <LoggedOut /> return <LoggedOut />
} }
if (hasSession && currentAccount?.deactivated) { if (hasSession && currentAccount?.signupQueued) {
return <Deactivated /> return <SignupQueued />
} }
if (showLoggedOut) { if (showLoggedOut) {
return <LoggedOut onDismiss={() => setShowLoggedOut(false)} /> return <LoggedOut onDismiss={() => setShowLoggedOut(false)} />