Ensure userMetadata is cleared when logging out
This commit is contained in:
@@ -67,7 +67,7 @@ if (env.IS_WEB) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let userMetadata: UserMetadata | null = null
|
let userMetadata: UserMetadata | null = null
|
||||||
export function updateUserMetadata(account: persisted.PersistedAccount | null) {
|
export function setUserMetadata(account: persisted.PersistedAccount | null) {
|
||||||
if (account === null) {
|
if (account === null) {
|
||||||
userMetadata = null
|
userMetadata = null
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import {
|
|||||||
import {getAge} from '#/lib/strings/time'
|
import {getAge} from '#/lib/strings/time'
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {refresh as refreshGates} from '#/logger/growthbook'
|
import {refresh as refreshGates} from '#/logger/growthbook'
|
||||||
import {updateUserMetadata} from '#/logger/metadata'
|
import {setUserMetadata} from '#/logger/metadata'
|
||||||
import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
|
import {snoozeBirthdateUpdateAllowedForDid} from '#/state/birthdate'
|
||||||
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
|
import {snoozeEmailConfirmationPrompt} from '#/state/shell/reminders'
|
||||||
import {
|
import {
|
||||||
@@ -64,7 +64,7 @@ export async function createAgentAndResume(
|
|||||||
if (storedAccount.pdsUrl) {
|
if (storedAccount.pdsUrl) {
|
||||||
agent.sessionManager.pdsUrl = new URL(storedAccount.pdsUrl)
|
agent.sessionManager.pdsUrl = new URL(storedAccount.pdsUrl)
|
||||||
}
|
}
|
||||||
updateUserMetadata(storedAccount)
|
setUserMetadata(storedAccount)
|
||||||
const gates = refreshGates({
|
const gates = refreshGates({
|
||||||
strategy: 'prefer-low-latency',
|
strategy: 'prefer-low-latency',
|
||||||
})
|
})
|
||||||
@@ -127,7 +127,7 @@ export async function createAgentAndLogin(
|
|||||||
})
|
})
|
||||||
|
|
||||||
const account = agentToSessionAccountOrThrow(agent)
|
const account = agentToSessionAccountOrThrow(agent)
|
||||||
updateUserMetadata(account)
|
setUserMetadata(account)
|
||||||
const gates = refreshGates({strategy: 'prefer-fresh-gates'})
|
const gates = refreshGates({strategy: 'prefer-fresh-gates'})
|
||||||
const moderation = configureModerationForAccount(agent, account)
|
const moderation = configureModerationForAccount(agent, account)
|
||||||
const aa = prefetchAgeAssuranceData({agent})
|
const aa = prefetchAgeAssuranceData({agent})
|
||||||
@@ -176,7 +176,7 @@ export async function createAgentAndCreateAccount(
|
|||||||
verificationCode,
|
verificationCode,
|
||||||
})
|
})
|
||||||
const account = agentToSessionAccountOrThrow(agent)
|
const account = agentToSessionAccountOrThrow(agent)
|
||||||
updateUserMetadata(account)
|
setUserMetadata(account)
|
||||||
const gates = refreshGates({strategy: 'prefer-fresh-gates'})
|
const gates = refreshGates({strategy: 'prefer-fresh-gates'})
|
||||||
const moderation = configureModerationForAccount(agent, account)
|
const moderation = configureModerationForAccount(agent, account)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {type AtpSessionEvent, type BskyAgent} from '@atproto/api'
|
import {type AtpSessionEvent, type BskyAgent} from '@atproto/api'
|
||||||
|
|
||||||
|
import {setUserMetadata} from '#/logger/metadata'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
import {useCloseAllActiveElements} from '#/state/util'
|
import {useCloseAllActiveElements} from '#/state/util'
|
||||||
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
|
import {useGlobalDialogsControlContext} from '#/components/dialogs/Context'
|
||||||
@@ -15,7 +16,6 @@ import {
|
|||||||
sessionAccountToSession,
|
sessionAccountToSession,
|
||||||
} from './agent'
|
} from './agent'
|
||||||
import {type Action, getInitialState, reducer, type State} from './reducer'
|
import {type Action, getInitialState, reducer, type State} from './reducer'
|
||||||
|
|
||||||
export {isSignupQueued} from './util'
|
export {isSignupQueued} from './util'
|
||||||
import {addSessionDebugLog} from './logging'
|
import {addSessionDebugLog} from './logging'
|
||||||
export type {SessionAccount} from '#/state/session/types'
|
export type {SessionAccount} from '#/state/session/types'
|
||||||
@@ -111,6 +111,9 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
accountDid,
|
accountDid,
|
||||||
sessionEvent,
|
sessionEvent,
|
||||||
})
|
})
|
||||||
|
if (!refreshedAccount) {
|
||||||
|
setUserMetadata(null)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[store],
|
[store],
|
||||||
)
|
)
|
||||||
@@ -170,8 +173,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
SessionApiContext['logoutCurrentAccount']
|
SessionApiContext['logoutCurrentAccount']
|
||||||
>(
|
>(
|
||||||
logContext => {
|
logContext => {
|
||||||
// TODO
|
|
||||||
// const gates = refreshGates({account, strategy: 'prefer-fresh-gates'})
|
|
||||||
addSessionDebugLog({type: 'method:start', method: 'logout'})
|
addSessionDebugLog({type: 'method:start', method: 'logout'})
|
||||||
cancelPendingTask()
|
cancelPendingTask()
|
||||||
const prevState = store.getState()
|
const prevState = store.getState()
|
||||||
@@ -184,6 +185,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
{statsig: true},
|
{statsig: true},
|
||||||
)
|
)
|
||||||
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
||||||
|
setUserMetadata(null)
|
||||||
if (prevState.currentAgentState.did) {
|
if (prevState.currentAgentState.did) {
|
||||||
clearAgeAssuranceDataForDid({did: prevState.currentAgentState.did})
|
clearAgeAssuranceDataForDid({did: prevState.currentAgentState.did})
|
||||||
}
|
}
|
||||||
@@ -208,6 +210,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
{statsig: true},
|
{statsig: true},
|
||||||
)
|
)
|
||||||
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
addSessionDebugLog({type: 'method:end', method: 'logout'})
|
||||||
|
setUserMetadata(null)
|
||||||
clearAgeAssuranceData()
|
clearAgeAssuranceData()
|
||||||
// reset onboarding flow on logout
|
// reset onboarding flow on logout
|
||||||
onboardingDispatch({type: 'skip'})
|
onboardingDispatch({type: 'skip'})
|
||||||
|
|||||||
Reference in New Issue
Block a user