Replace updateCurrentAccount() with refreshSession() (#3910)
Replace updateCurrentAccount() with resumeSession()zio/stable
parent
f62b0458a7
commit
0c6bf276dd
|
@ -1302,177 +1302,6 @@ describe('session', () => {
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('updates current account', () => {
|
|
||||||
let state = getInitialState([])
|
|
||||||
|
|
||||||
const agent1 = new BskyAgent({service: 'https://alice.com'})
|
|
||||||
agent1.session = {
|
|
||||||
did: 'alice-did',
|
|
||||||
handle: 'alice.test',
|
|
||||||
accessJwt: 'alice-access-jwt-1',
|
|
||||||
refreshJwt: 'alice-refresh-jwt-1',
|
|
||||||
}
|
|
||||||
state = run(state, [
|
|
||||||
{
|
|
||||||
type: 'switched-to-account',
|
|
||||||
newAgent: agent1,
|
|
||||||
newAccount: agentToSessionAccountOrThrow(agent1),
|
|
||||||
},
|
|
||||||
])
|
|
||||||
expect(state.accounts.length).toBe(1)
|
|
||||||
expect(state.accounts[0].accessJwt).toBe('alice-access-jwt-1')
|
|
||||||
expect(state.currentAgentState.did).toBe('alice-did')
|
|
||||||
|
|
||||||
state = run(state, [
|
|
||||||
{
|
|
||||||
type: 'updated-current-account',
|
|
||||||
updatedFields: {
|
|
||||||
email: 'alice@foo.bar',
|
|
||||||
emailConfirmed: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
expect(state.accounts.length).toBe(1)
|
|
||||||
expect(state.accounts[0].email).toBe('alice@foo.bar')
|
|
||||||
expect(state.accounts[0].emailConfirmed).toBe(false)
|
|
||||||
expect(state.currentAgentState.did).toBe('alice-did')
|
|
||||||
expect(printState(state)).toMatchInlineSnapshot(`
|
|
||||||
{
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"accessJwt": "alice-access-jwt-1",
|
|
||||||
"deactivated": false,
|
|
||||||
"did": "alice-did",
|
|
||||||
"email": "alice@foo.bar",
|
|
||||||
"emailAuthFactor": false,
|
|
||||||
"emailConfirmed": false,
|
|
||||||
"handle": "alice.test",
|
|
||||||
"pdsUrl": undefined,
|
|
||||||
"refreshJwt": "alice-refresh-jwt-1",
|
|
||||||
"service": "https://alice.com/",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"currentAgentState": {
|
|
||||||
"agent": {
|
|
||||||
"service": "https://alice.com/",
|
|
||||||
},
|
|
||||||
"did": "alice-did",
|
|
||||||
},
|
|
||||||
"needsPersist": true,
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
state = run(state, [
|
|
||||||
{
|
|
||||||
type: 'updated-current-account',
|
|
||||||
updatedFields: {
|
|
||||||
handle: 'alice-updated.test',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
expect(state.accounts.length).toBe(1)
|
|
||||||
expect(state.accounts[0].handle).toBe('alice-updated.test')
|
|
||||||
expect(state.currentAgentState.did).toBe('alice-did')
|
|
||||||
expect(printState(state)).toMatchInlineSnapshot(`
|
|
||||||
{
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"accessJwt": "alice-access-jwt-1",
|
|
||||||
"deactivated": false,
|
|
||||||
"did": "alice-did",
|
|
||||||
"email": "alice@foo.bar",
|
|
||||||
"emailAuthFactor": false,
|
|
||||||
"emailConfirmed": false,
|
|
||||||
"handle": "alice-updated.test",
|
|
||||||
"pdsUrl": undefined,
|
|
||||||
"refreshJwt": "alice-refresh-jwt-1",
|
|
||||||
"service": "https://alice.com/",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"currentAgentState": {
|
|
||||||
"agent": {
|
|
||||||
"service": "https://alice.com/",
|
|
||||||
},
|
|
||||||
"did": "alice-did",
|
|
||||||
},
|
|
||||||
"needsPersist": true,
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
|
|
||||||
const agent2 = new BskyAgent({service: 'https://bob.com'})
|
|
||||||
agent2.session = {
|
|
||||||
did: 'bob-did',
|
|
||||||
handle: 'bob.test',
|
|
||||||
accessJwt: 'bob-access-jwt-1',
|
|
||||||
refreshJwt: 'bob-refresh-jwt-1',
|
|
||||||
}
|
|
||||||
state = run(state, [
|
|
||||||
{
|
|
||||||
// Switch to Bob.
|
|
||||||
type: 'switched-to-account',
|
|
||||||
newAgent: agent2,
|
|
||||||
newAccount: agentToSessionAccountOrThrow(agent2),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Update Bob.
|
|
||||||
type: 'updated-current-account',
|
|
||||||
updatedFields: {
|
|
||||||
handle: 'bob-updated.test',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Switch back to Alice.
|
|
||||||
type: 'switched-to-account',
|
|
||||||
newAgent: agent1,
|
|
||||||
newAccount: agentToSessionAccountOrThrow(agent1),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Update Alice.
|
|
||||||
type: 'updated-current-account',
|
|
||||||
updatedFields: {
|
|
||||||
handle: 'alice-updated-2.test',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
])
|
|
||||||
expect(printState(state)).toMatchInlineSnapshot(`
|
|
||||||
{
|
|
||||||
"accounts": [
|
|
||||||
{
|
|
||||||
"accessJwt": "alice-access-jwt-1",
|
|
||||||
"deactivated": false,
|
|
||||||
"did": "alice-did",
|
|
||||||
"email": undefined,
|
|
||||||
"emailAuthFactor": false,
|
|
||||||
"emailConfirmed": false,
|
|
||||||
"handle": "alice-updated-2.test",
|
|
||||||
"pdsUrl": undefined,
|
|
||||||
"refreshJwt": "alice-refresh-jwt-1",
|
|
||||||
"service": "https://alice.com/",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"accessJwt": "bob-access-jwt-1",
|
|
||||||
"deactivated": false,
|
|
||||||
"did": "bob-did",
|
|
||||||
"email": undefined,
|
|
||||||
"emailAuthFactor": false,
|
|
||||||
"emailConfirmed": false,
|
|
||||||
"handle": "bob-updated.test",
|
|
||||||
"pdsUrl": undefined,
|
|
||||||
"refreshJwt": "bob-refresh-jwt-1",
|
|
||||||
"service": "https://bob.com/",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"currentAgentState": {
|
|
||||||
"agent": {
|
|
||||||
"service": "https://alice.com/",
|
|
||||||
},
|
|
||||||
"did": "alice-did",
|
|
||||||
},
|
|
||||||
"needsPersist": true,
|
|
||||||
}
|
|
||||||
`)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('replaces local accounts with synced accounts', () => {
|
it('replaces local accounts with synced accounts', () => {
|
||||||
let state = getInitialState([])
|
let state = getInitialState([])
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ const ApiContext = React.createContext<SessionApiContext>({
|
||||||
logout: async () => {},
|
logout: async () => {},
|
||||||
resumeSession: async () => {},
|
resumeSession: async () => {},
|
||||||
removeAccount: () => {},
|
removeAccount: () => {},
|
||||||
updateCurrentAccount: () => {},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
|
@ -149,15 +148,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
[cancelPendingTask],
|
[cancelPendingTask],
|
||||||
)
|
)
|
||||||
|
|
||||||
const updateCurrentAccount = React.useCallback<
|
|
||||||
SessionApiContext['updateCurrentAccount']
|
|
||||||
>(account => {
|
|
||||||
dispatch({
|
|
||||||
type: 'updated-current-account',
|
|
||||||
updatedFields: account,
|
|
||||||
})
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (state.needsPersist) {
|
if (state.needsPersist) {
|
||||||
state.needsPersist = false
|
state.needsPersist = false
|
||||||
|
@ -210,16 +200,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
logout,
|
logout,
|
||||||
resumeSession,
|
resumeSession,
|
||||||
removeAccount,
|
removeAccount,
|
||||||
updateCurrentAccount,
|
|
||||||
}),
|
}),
|
||||||
[
|
[createAccount, login, logout, resumeSession, removeAccount],
|
||||||
createAccount,
|
|
||||||
login,
|
|
||||||
logout,
|
|
||||||
resumeSession,
|
|
||||||
removeAccount,
|
|
||||||
updateCurrentAccount,
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
|
|
@ -36,15 +36,6 @@ export type Action =
|
||||||
newAgent: OpaqueBskyAgent
|
newAgent: OpaqueBskyAgent
|
||||||
newAccount: SessionAccount
|
newAccount: SessionAccount
|
||||||
}
|
}
|
||||||
| {
|
|
||||||
type: 'updated-current-account'
|
|
||||||
updatedFields: Partial<
|
|
||||||
Pick<
|
|
||||||
SessionAccount,
|
|
||||||
'handle' | 'email' | 'emailConfirmed' | 'emailAuthFactor'
|
|
||||||
>
|
|
||||||
>
|
|
||||||
}
|
|
||||||
| {
|
| {
|
||||||
type: 'removed-account'
|
type: 'removed-account'
|
||||||
accountDid: string
|
accountDid: string
|
||||||
|
@ -134,23 +125,6 @@ export function reducer(state: State, action: Action): State {
|
||||||
needsPersist: true,
|
needsPersist: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'updated-current-account': {
|
|
||||||
const {updatedFields} = action
|
|
||||||
return {
|
|
||||||
accounts: state.accounts.map(a => {
|
|
||||||
if (a.did === state.currentAgentState.did) {
|
|
||||||
return {
|
|
||||||
...a,
|
|
||||||
...updatedFields,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
currentAgentState: state.currentAgentState,
|
|
||||||
needsPersist: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 'removed-account': {
|
case 'removed-account': {
|
||||||
const {accountDid} = action
|
const {accountDid} = action
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -37,12 +37,4 @@ export type SessionApiContext = {
|
||||||
logout: (logContext: LogEvents['account:loggedOut']['logContext']) => void
|
logout: (logContext: LogEvents['account:loggedOut']['logContext']) => void
|
||||||
resumeSession: (account: SessionAccount) => Promise<void>
|
resumeSession: (account: SessionAccount) => Promise<void>
|
||||||
removeAccount: (account: SessionAccount) => void
|
removeAccount: (account: SessionAccount) => void
|
||||||
updateCurrentAccount: (
|
|
||||||
account: Partial<
|
|
||||||
Pick<
|
|
||||||
SessionAccount,
|
|
||||||
'handle' | 'email' | 'emailConfirmed' | 'emailAuthFactor'
|
|
||||||
>
|
|
||||||
>,
|
|
||||||
) => void
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {msg, Trans} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
|
@ -28,7 +28,6 @@ export function Component() {
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const [stage, setStage] = useState<Stages>(Stages.InputEmail)
|
const [stage, setStage] = useState<Stages>(Stages.InputEmail)
|
||||||
const [email, setEmail] = useState<string>(currentAccount?.email || '')
|
const [email, setEmail] = useState<string>(currentAccount?.email || '')
|
||||||
|
@ -51,10 +50,7 @@ export function Component() {
|
||||||
setStage(Stages.ConfirmCode)
|
setStage(Stages.ConfirmCode)
|
||||||
} else {
|
} else {
|
||||||
await getAgent().com.atproto.server.updateEmail({email: email.trim()})
|
await getAgent().com.atproto.server.updateEmail({email: email.trim()})
|
||||||
updateCurrentAccount({
|
await getAgent().resumeSession(getAgent().session!)
|
||||||
email: email.trim(),
|
|
||||||
emailConfirmed: false,
|
|
||||||
})
|
|
||||||
Toast.show(_(msg`Email updated`))
|
Toast.show(_(msg`Email updated`))
|
||||||
setStage(Stages.Done)
|
setStage(Stages.Done)
|
||||||
}
|
}
|
||||||
|
@ -83,10 +79,7 @@ export function Component() {
|
||||||
email: email.trim(),
|
email: email.trim(),
|
||||||
token: confirmationCode.trim(),
|
token: confirmationCode.trim(),
|
||||||
})
|
})
|
||||||
updateCurrentAccount({
|
await getAgent().resumeSession(getAgent().session!)
|
||||||
email: email.trim(),
|
|
||||||
emailConfirmed: false,
|
|
||||||
})
|
|
||||||
Toast.show(_(msg`Email updated`))
|
Toast.show(_(msg`Email updated`))
|
||||||
setStage(Stages.Done)
|
setStage(Stages.Done)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -15,12 +15,7 @@ import {logger} from '#/logger'
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {useFetchDid, useUpdateHandleMutation} from '#/state/queries/handle'
|
import {useFetchDid, useUpdateHandleMutation} from '#/state/queries/handle'
|
||||||
import {useServiceQuery} from '#/state/queries/service'
|
import {useServiceQuery} from '#/state/queries/service'
|
||||||
import {
|
import {SessionAccount, useAgent, useSession} from '#/state/session'
|
||||||
SessionAccount,
|
|
||||||
useAgent,
|
|
||||||
useSession,
|
|
||||||
useSessionApi,
|
|
||||||
} from '#/state/session'
|
|
||||||
import {useAnalytics} from 'lib/analytics/analytics'
|
import {useAnalytics} from 'lib/analytics/analytics'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
|
@ -73,10 +68,10 @@ export function Inner({
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {track} = useAnalytics()
|
const {track} = useAnalytics()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
|
||||||
const {closeModal} = useModalControls()
|
const {closeModal} = useModalControls()
|
||||||
const {mutateAsync: updateHandle, isPending: isUpdateHandlePending} =
|
const {mutateAsync: updateHandle, isPending: isUpdateHandlePending} =
|
||||||
useUpdateHandleMutation()
|
useUpdateHandleMutation()
|
||||||
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const [error, setError] = useState<string>('')
|
const [error, setError] = useState<string>('')
|
||||||
|
|
||||||
|
@ -116,9 +111,7 @@ export function Inner({
|
||||||
await updateHandle({
|
await updateHandle({
|
||||||
handle: newHandle,
|
handle: newHandle,
|
||||||
})
|
})
|
||||||
updateCurrentAccount({
|
await getAgent().resumeSession(getAgent().session!)
|
||||||
handle: newHandle,
|
|
||||||
})
|
|
||||||
closeModal()
|
closeModal()
|
||||||
onChanged()
|
onChanged()
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
|
@ -134,9 +127,9 @@ export function Inner({
|
||||||
onChanged,
|
onChanged,
|
||||||
track,
|
track,
|
||||||
closeModal,
|
closeModal,
|
||||||
updateCurrentAccount,
|
|
||||||
updateHandle,
|
updateHandle,
|
||||||
serviceInfo,
|
serviceInfo,
|
||||||
|
getAgent,
|
||||||
])
|
])
|
||||||
|
|
||||||
// rendering
|
// rendering
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {usePalette} from 'lib/hooks/usePalette'
|
import {usePalette} from 'lib/hooks/usePalette'
|
||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
|
@ -43,7 +43,6 @@ export function Component({
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const [stage, setStage] = useState<Stages>(
|
const [stage, setStage] = useState<Stages>(
|
||||||
showReminder ? Stages.Reminder : Stages.Email,
|
showReminder ? Stages.Reminder : Stages.Email,
|
||||||
|
@ -82,7 +81,7 @@ export function Component({
|
||||||
email: (currentAccount?.email || '').trim(),
|
email: (currentAccount?.email || '').trim(),
|
||||||
token: confirmationCode.trim(),
|
token: confirmationCode.trim(),
|
||||||
})
|
})
|
||||||
updateCurrentAccount({emailConfirmed: true})
|
await getAgent().resumeSession(getAgent().session!)
|
||||||
Toast.show(_(msg`Email verified`))
|
Toast.show(_(msg`Email verified`))
|
||||||
closeModal()
|
closeModal()
|
||||||
onSuccess?.()
|
onSuccess?.()
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {cleanError} from '#/lib/strings/errors'
|
import {cleanError} from '#/lib/strings/errors'
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
import {ErrorMessage} from '#/view/com/util/error/ErrorMessage'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
import {atoms as a, useBreakpoints, useTheme} from '#/alf'
|
||||||
|
@ -30,7 +30,6 @@ export function DisableEmail2FADialog({
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
|
||||||
const [stage, setStage] = useState<Stages>(Stages.Email)
|
const [stage, setStage] = useState<Stages>(Stages.Email)
|
||||||
|
@ -61,7 +60,7 @@ export function DisableEmail2FADialog({
|
||||||
token: confirmationCode.trim(),
|
token: confirmationCode.trim(),
|
||||||
emailAuthFactor: false,
|
emailAuthFactor: false,
|
||||||
})
|
})
|
||||||
updateCurrentAccount({emailAuthFactor: false})
|
await getAgent().resumeSession(getAgent().session!)
|
||||||
Toast.show(_(msg`Email 2FA disabled`))
|
Toast.show(_(msg`Email 2FA disabled`))
|
||||||
}
|
}
|
||||||
control.close()
|
control.close()
|
||||||
|
|
|
@ -3,7 +3,7 @@ import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useModalControls} from '#/state/modals'
|
import {useModalControls} from '#/state/modals'
|
||||||
import {useAgent, useSession, useSessionApi} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {ToggleButton} from 'view/com/util/forms/ToggleButton'
|
import {ToggleButton} from 'view/com/util/forms/ToggleButton'
|
||||||
import {useDialogControl} from '#/components/Dialog'
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
import {DisableEmail2FADialog} from './DisableEmail2FADialog'
|
import {DisableEmail2FADialog} from './DisableEmail2FADialog'
|
||||||
|
@ -11,7 +11,6 @@ import {DisableEmail2FADialog} from './DisableEmail2FADialog'
|
||||||
export function Email2FAToggle() {
|
export function Email2FAToggle() {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const {updateCurrentAccount} = useSessionApi()
|
|
||||||
const {openModal} = useModalControls()
|
const {openModal} = useModalControls()
|
||||||
const disableDialogCtrl = useDialogControl()
|
const disableDialogCtrl = useDialogControl()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
|
@ -22,11 +21,9 @@ export function Email2FAToggle() {
|
||||||
email: currentAccount.email,
|
email: currentAccount.email,
|
||||||
emailAuthFactor: true,
|
emailAuthFactor: true,
|
||||||
})
|
})
|
||||||
updateCurrentAccount({
|
await getAgent().resumeSession(getAgent().session!)
|
||||||
emailAuthFactor: true,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}, [currentAccount, updateCurrentAccount, getAgent])
|
}, [currentAccount, getAgent])
|
||||||
|
|
||||||
const onToggle = React.useCallback(() => {
|
const onToggle = React.useCallback(() => {
|
||||||
if (!currentAccount) {
|
if (!currentAccount) {
|
||||||
|
|
Loading…
Reference in New Issue