StanfordSpezi / SpeziAccount

The Spezi Account module to enable login and signup functionality
https://swiftpackageindex.com/StanfordSpezi/SpeziAccount/documentation/
MIT License
5 stars 5 forks source link

Support receiving updates from custom data storage layer #43

Closed Supereg closed 4 weeks ago

Supereg commented 9 months ago

Problem

Currently, an AccountService is the only authority to notify the global Account object of updated AccountDetails. An external storage provider is queried automatically (see AccountStorageStandard/load(::) by SpeziAccount on such occasions to build the complete AccountDetails object.

Below is an illustration of the general flow when a call to Account/supplyUserDetails(_:isNewUser:) is done by the current AccountService:

1. Account Service calls `Account/supplyUserDetails(_:isNewUser:)` with `details`.
2. Account services calls `AccountStorageStandard/load(_:_:)` to query additional account details stored externally.
3. The `Account/details` property is updated with all user information.

The current problem is, that an AccountStorageStandard cannot update the account details itself. It has to wait till the current AccountService may choose to call supplyUserDetails(_:isNewUser:).

Solution

To resolve this issue, we might want to add functionality, to allow an AccountStorageStandard to arbitrarily update account details (e.g., when a database record is manually or externally changed) such that Account always reflects the latest state.

Additional context

No response

Code of Conduct