Security module¶
Account security settings for authenticated investors: password change, MFA toggle, and connected-device management.
Route: account/security → SecurityScreen (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
ChangePasswordSectionUIopensChangePasswordModalviauseModals().openModal. - Validation:
changePasswordValidator(passwordValidator+ confirm match +revokeOtherSessionsboolean). - Submit:
authClient.changePasswordthroughuseChangePassword. On success withrevokeOtherSessions, invalidatesauthQueryKeys.sessions.
See also: ../auth/AUTH_FLOWS.md (flows 6–7).
Connected devices¶
- Lists Better Auth sessions via
authClient.listSessions. buildConnectedDeviceItemsmaps sessions to display rows; current session is identified by comparing session token toauthClient.useSession().- Revoke calls
authClient.revokeSession({ token })then refetches the list.
Query key: authQueryKeys.sessions in modules/auth/services/queryKeys.ts (meta.persist: false).
Related docs¶
- Auth API map:
../auth/AUTH_FLOWS.md - Better Auth server:
../../../../api/src/lib/better-auth/README.md