Aller au contenu

Security module

Account security settings for authenticated investors: password change, MFA toggle, and connected-device management.

Route: account/securitySecurityScreen (src/app/(authenticated)/(tabs)/account/security.tsx).

Screen layout (Pattern A)

SecurityScreen composes SecurityContainer with three independent slots (each section owns its own data fetching):

Slot Smart component Data source
passwordSection ChangePasswordSection useChangePassword → Better Auth changePassword
authenticationSection AuthenticationSection Investor account + useUpdateMfaEnabled / useConfirmMfaCode (legacy MFA API for enable/disable)
connectedDevicesSection ConnectedDevicesSection useListSessions / useRevokeSession → Better Auth session APIs

Storybook uses SecurityContainer + *Preview exports from each section's *UI.stories.tsx (securityContainerDecorator).

Change password

  • Entry: button on ChangePasswordSectionUI opens ChangePasswordModal via useModals().openModal.
  • Validation: changePasswordValidator (passwordValidator + confirm match + revokeOtherSessions boolean).
  • Submit: authClient.changePassword through useChangePassword. On success with revokeOtherSessions, invalidates authQueryKeys.sessions.

See also: ../auth/AUTH_FLOWS.md (flows 6–7).

Connected devices

  • Lists Better Auth sessions via authClient.listSessions.
  • buildConnectedDeviceItems maps sessions to display rows; current session is identified by comparing session token to authClient.useSession().
  • Revoke calls authClient.revokeSession({ token }) then refetches the list.

Query key: authQueryKeys.sessions in modules/auth/services/queryKeys.ts (meta.persist: false).