[Session] Fix stale emailAuthFactor and emailConfirmed on the client (#3835)
* Fix account refresh to not clobber falsy values * Use ?? in more placeszio/stable
parent
0f827c3213
commit
c13685a0cf
|
@ -121,11 +121,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
// TODO: use agentToSessionAccount for this too.
|
// TODO: use agentToSessionAccount for this too.
|
||||||
const refreshedAccount: SessionAccount = {
|
const refreshedAccount: SessionAccount = {
|
||||||
service: account.service,
|
service: account.service,
|
||||||
did: session?.did || account.did,
|
did: session?.did ?? account.did,
|
||||||
handle: session?.handle || account.handle,
|
handle: session?.handle ?? account.handle,
|
||||||
email: session?.email || account.email,
|
email: session?.email ?? account.email,
|
||||||
emailConfirmed: session?.emailConfirmed || account.emailConfirmed,
|
emailConfirmed: session?.emailConfirmed ?? account.emailConfirmed,
|
||||||
emailAuthFactor: session?.emailAuthFactor || account.emailAuthFactor,
|
emailAuthFactor: session?.emailAuthFactor ?? account.emailAuthFactor,
|
||||||
deactivated: isSessionDeactivated(session?.accessJwt),
|
deactivated: isSessionDeactivated(session?.accessJwt),
|
||||||
pdsUrl: agent.pdsUrl?.toString(),
|
pdsUrl: agent.pdsUrl?.toString(),
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
isSessionDeactivated(account.accessJwt) || account.deactivated
|
isSessionDeactivated(account.accessJwt) || account.deactivated
|
||||||
|
|
||||||
const prevSession = {
|
const prevSession = {
|
||||||
accessJwt: account.accessJwt || '',
|
accessJwt: account.accessJwt ?? '',
|
||||||
refreshJwt: account.refreshJwt || '',
|
refreshJwt: account.refreshJwt ?? '',
|
||||||
did: account.did,
|
did: account.did,
|
||||||
handle: account.handle,
|
handle: account.handle,
|
||||||
}
|
}
|
||||||
|
@ -457,16 +457,12 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
|
|
||||||
const updatedAccount = {
|
const updatedAccount = {
|
||||||
...currentAccount,
|
...currentAccount,
|
||||||
handle: account.handle || currentAccount.handle,
|
handle: account.handle ?? currentAccount.handle,
|
||||||
email: account.email || currentAccount.email,
|
email: account.email ?? currentAccount.email,
|
||||||
emailConfirmed:
|
emailConfirmed:
|
||||||
account.emailConfirmed !== undefined
|
account.emailConfirmed ?? currentAccount.emailConfirmed,
|
||||||
? account.emailConfirmed
|
|
||||||
: currentAccount.emailConfirmed,
|
|
||||||
emailAuthFactor:
|
emailAuthFactor:
|
||||||
account.emailAuthFactor !== undefined
|
account.emailAuthFactor ?? currentAccount.emailAuthFactor,
|
||||||
? account.emailAuthFactor
|
|
||||||
: currentAccount.emailAuthFactor,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue