feat: Add getCurrentUser API Method to Formulus #256
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description
Overview
Adds a new getCurrentUser() method to the Formulus API that retrieves the authenticated username from the device's secure Keychain storage. This enables WebView apps (like AnthroCollect) to access the logged-in user information without requiring manual re-selection.
Closes https://github.com/Omo-Valley-Research-Project/AnthroCollect/issues/32
Changes
Implementation
API Method Signature:
getCurrentUser(): Promise<{username: string, displayName?: string}>Return Value Example:
How It Works:
Bug Fix Included
Issue: Injection script generator was outputting invalid TypeScript syntax in JavaScript files
This was causing linter errors like "Expression expected" and "Declaration or statement expected"
Fixed by removing TypeScript interface declarations from the JavaScript output template
Dependencies
Required by the corresponding AnthroCollect PR that removes the redundant user selection screen
Testing Checklist
Technical Notes
• Username is stored in Keychain during login (Keychain.setGenericPassword)
• Method uses Keychain.getGenericPassword() to retrieve credentials securely
• Returns displayName field for future extensibility (e.g., mapping to full names)
• No breaking changes to existing API methods
• Injection scripts are auto-generated - run npm run generate after modifying the interface
Screenshot showing username an village