[🙅] Disambiguation of the deactivation (#4267)
* Disambiguation of the deactivation * Snapshot crackle pop * Change log context * [🙅] Add status to session state (#4269) * Add status to session state * [🙅] Add new deactivated screen (#4270) * Add new deactivated screen * Update copy, handle logout * Remove icons, adjust padding * [🙅] Add deactivate account dialog (#4290) * Deactivate dialog (cherry picked from commit 33940e2dfe0d710c0665a7f68b198b46f54db4a2) * Factor out dialog, add to delete modal too (cherry picked from commit 47d70f6b74e7d2ea7330fd172499fe91ba41062d) * Update copy, icon (cherry picked from commit e6efabbe78c3f3d9f0f8fb0a06a6a1c4fbfb70a9) * Update copy (cherry picked from commit abb0ce26f6747ab0548f6f12df0dee3c64464852) * Sizing tweaks (cherry picked from commit fc716d5716873f0fddef56496fc48af0614b2e55) * Add a11y label
This commit is contained in:
parent
de93e8de74
commit
3e1f076891
12 changed files with 578 additions and 224 deletions
|
@ -17,7 +17,10 @@ const accountSchema = z.object({
|
|||
emailAuthFactor: z.boolean().optional(),
|
||||
refreshJwt: 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(),
|
||||
status: z
|
||||
.enum(['active', 'takendown', 'suspended', 'deactivated'])
|
||||
.optional(),
|
||||
pdsUrl: z.string().optional(),
|
||||
})
|
||||
export type PersistedAccount = z.infer<typeof accountSchema>
|
||||
|
|
|
@ -50,7 +50,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -59,6 +58,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-1",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -87,7 +88,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": undefined,
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -96,6 +96,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": undefined,
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -136,7 +138,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -145,6 +146,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-1",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -183,7 +186,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "bob-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -192,10 +194,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "bob-refresh-jwt-1",
|
||||
"service": "https://bob.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -204,6 +207,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-1",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -242,7 +247,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -251,10 +255,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-2",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": "bob-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -263,6 +268,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "bob-refresh-jwt-1",
|
||||
"service": "https://bob.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -299,7 +306,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "jay-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "jay-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -308,10 +314,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "jay-refresh-jwt-1",
|
||||
"service": "https://jay.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -320,10 +327,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-2",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": "bob-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -332,6 +340,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "bob-refresh-jwt-1",
|
||||
"service": "https://bob.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -364,7 +374,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": undefined,
|
||||
"deactivated": false,
|
||||
"did": "jay-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -373,10 +382,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": undefined,
|
||||
"service": "https://jay.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": undefined,
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -385,10 +395,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": undefined,
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": undefined,
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -397,6 +408,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": undefined,
|
||||
"service": "https://bob.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -446,7 +459,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": undefined,
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -455,6 +467,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": undefined,
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -490,7 +504,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -499,6 +512,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-2",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -601,7 +616,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "bob-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -610,6 +624,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "bob-refresh-jwt-1",
|
||||
"service": "https://bob.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -681,7 +697,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": "alice@foo.bar",
|
||||
"emailAuthFactor": false,
|
||||
|
@ -690,6 +705,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-2",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -731,7 +748,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-3",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": "alice@foo.baz",
|
||||
"emailAuthFactor": true,
|
||||
|
@ -740,6 +756,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-3",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -781,7 +799,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-4",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": "alice@foo.baz",
|
||||
"emailAuthFactor": false,
|
||||
|
@ -790,6 +807,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-4",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -937,7 +956,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "bob-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -946,10 +964,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "bob-refresh-jwt-1",
|
||||
"service": "https://bob.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": "alice@foo.bar",
|
||||
"emailAuthFactor": false,
|
||||
|
@ -958,6 +977,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-2",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -997,7 +1018,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "bob-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1006,10 +1026,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "bob-refresh-jwt-2",
|
||||
"service": "https://bob.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": "alice@foo.bar",
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1018,6 +1039,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-2",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -1156,7 +1179,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "alice-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1165,6 +1187,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "alice-refresh-jwt-1",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -1218,7 +1242,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": undefined,
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1227,6 +1250,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": undefined,
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -1280,7 +1305,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": undefined,
|
||||
"deactivated": false,
|
||||
"did": "alice-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1289,6 +1313,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": undefined,
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -1371,7 +1397,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "jay-access-jwt-1",
|
||||
"deactivated": false,
|
||||
"did": "jay-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1380,10 +1405,11 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "jay-refresh-jwt-1",
|
||||
"service": "https://jay.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
{
|
||||
"accessJwt": "bob-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "bob-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1392,6 +1418,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "bob-refresh-jwt-2",
|
||||
"service": "https://alice.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
@ -1429,7 +1457,6 @@ describe('session', () => {
|
|||
"accounts": [
|
||||
{
|
||||
"accessJwt": "clarence-access-jwt-2",
|
||||
"deactivated": false,
|
||||
"did": "clarence-did",
|
||||
"email": undefined,
|
||||
"emailAuthFactor": false,
|
||||
|
@ -1438,6 +1465,8 @@ describe('session', () => {
|
|||
"pdsUrl": undefined,
|
||||
"refreshJwt": "clarence-refresh-jwt-2",
|
||||
"service": "https://clarence.com/",
|
||||
"signupQueued": false,
|
||||
"status": "active",
|
||||
},
|
||||
],
|
||||
"currentAgentState": {
|
||||
|
|
|
@ -16,7 +16,7 @@ import {
|
|||
configureModerationForGuest,
|
||||
} from './moderation'
|
||||
import {SessionAccount} from './types'
|
||||
import {isSessionDeactivated, isSessionExpired} from './util'
|
||||
import {isSessionExpired, isSignupQueued} from './util'
|
||||
|
||||
export function createPublicAgent() {
|
||||
configureModerationForGuest() // Side effect but only relevant for tests
|
||||
|
@ -51,7 +51,7 @@ export async function createAgentAndResume(
|
|||
await networkRetry(1, () => agent.resumeSession(prevSession))
|
||||
} else {
|
||||
agent.session = prevSession
|
||||
if (!storedAccount.deactivated) {
|
||||
if (!storedAccount.signupQueued) {
|
||||
// Intentionally not awaited to unblock the UI:
|
||||
networkRetry(3, () => agent.resumeSession(prevSession)).catch(
|
||||
(e: any) => {
|
||||
|
@ -135,7 +135,7 @@ export async function createAgentAndCreateAccount(
|
|||
const account = agentToSessionAccountOrThrow(agent)
|
||||
const gates = tryFetchGates(account.did, 'prefer-fresh-gates')
|
||||
const moderation = configureModerationForAccount(agent, account)
|
||||
if (!account.deactivated) {
|
||||
if (!account.signupQueued) {
|
||||
/*dont await*/ agent.upsertProfile(_existing => {
|
||||
return {
|
||||
displayName: '',
|
||||
|
@ -234,7 +234,9 @@ export function agentToSessionAccount(
|
|||
emailAuthFactor: agent.session.emailAuthFactor || false,
|
||||
refreshJwt: agent.session.refreshJwt,
|
||||
accessJwt: agent.session.accessJwt,
|
||||
deactivated: isSessionDeactivated(agent.session.accessJwt),
|
||||
signupQueued: isSignupQueued(agent.session.accessJwt),
|
||||
// @ts-expect-error TODO remove when backend is ready
|
||||
status: agent.session.status || 'active',
|
||||
pdsUrl: agent.pdsUrl?.toString(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
} from './agent'
|
||||
import {getInitialState, reducer} from './reducer'
|
||||
|
||||
export {isSessionDeactivated} from './util'
|
||||
export {isSignupQueued} from './util'
|
||||
export type {SessionAccount} from '#/state/session/types'
|
||||
import {SessionApiContext, SessionStateContext} from '#/state/session/types'
|
||||
|
||||
|
|
|
@ -10,11 +10,12 @@ export function readLastActiveAccount() {
|
|||
return accounts.find(a => a.did === currentAccount?.did)
|
||||
}
|
||||
|
||||
export function isSessionDeactivated(accessJwt: string | undefined) {
|
||||
export function isSignupQueued(accessJwt: string | undefined) {
|
||||
if (accessJwt) {
|
||||
const sessData = jwtDecode(accessJwt)
|
||||
return (
|
||||
hasProp(sessData, 'scope') && sessData.scope === 'com.atproto.deactivated'
|
||||
hasProp(sessData, 'scope') &&
|
||||
sessData.scope === 'com.atproto.signupQueued'
|
||||
)
|
||||
}
|
||||
return false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue