TECHX-7034 fixed invalid credential type#162
Conversation
…auth Optional longer body (if you want a multi-line commit message): Replace username-based auth payloads with email/password across Initialize -> userSlice -> bWellSdk. This aligns with SDK credential guards (UserPassCredentials expects email + password) and fixes login failures in username/password environments like bwell_demo and bwell_trial.
There was a problem hiding this comment.
Pull request overview
This PR updates the example web app’s credential handling to address an “invalid credential type” issue when authenticating with the @icanbwell/bwell-sdk-ts SDK, shifting the UI/state from “username” to “email” and adding a compatibility fallback in the SDK wrapper.
Changes:
- Update username/password login flow to email/password across UI and Redux thunk parameters.
- Add a retry strategy in
authenticateSdkto support SDK versions that expect different credential shapes. - Bump
@icanbwell/bwell-sdk-tsdependency (and associated lockfile updates).
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
bwell-typescript-react/src/store/userSlice.ts |
Updates thunk param shape and return value to use email instead of username. |
bwell-typescript-react/src/sdk/bWellSdk.ts |
Updates SDK auth wrapper to accept { email, password } and adds credential-shape fallback logic. |
bwell-typescript-react/src/pages/Initialize.tsx |
Updates Initialize/login UI copy and wiring from username to email. |
bwell-typescript-react/package.json |
Bumps @icanbwell/bwell-sdk-ts version. |
bwell-typescript-react/package-lock.json |
Lockfile update for new SDK version and transitive deps. |
Files not reviewed (1)
- bwell-typescript-react/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!success) | ||
| return rejectWithValue(authenticationOutcome.error().message ?? "Unknown error"); | ||
| return params.oauthCreds ?? params.username ?? ""; | ||
| return params.oauthCreds ?? params.email ?? ""; |
There was a problem hiding this comment.
authenticate returns params.oauthCreds ?? params.email, and the fulfilled reducer stores that payload into state.oauthCreds. Because oauthCreds is later used as an OAuth token during redux-persist rehydration (passed to authenticateSdk(oauthCreds) as a string), persisting an email here will break rehydration and attempt token auth with an email. Consider returning/storing only the OAuth token value in oauthCreds (and not persisting anything for email/password login), or splitting state into separate fields (e.g., oauthToken vs email) so rehydration always has a real token.
| !usernameAttempt.success() && | ||
| usernameAttempt.error()?.message?.includes('Invalid credentials type provided') | ||
| ) { | ||
| return bWellSdk.authenticate({ email: creds.email, password: creds.password } as any); | ||
| } |
There was a problem hiding this comment.
The fallback path relies on matching a specific error message string (includes('Invalid credentials type provided')) and then uses as any to bypass typing for the { email, password } credential shape. This is brittle (message text changes break the fallback) and removes type-safety. Prefer checking a structured error property if available (e.g., error code/kind), and updating the SDK/auth types (or providing a typed wrapper/overload) so the retry call can be made without any.
| const loginWithProvidedOAuthCreds = () => dispatch(authenticate({ oauthCreds })); | ||
|
|
||
| const loginWithProvidedUsernamePassword = () => dispatch(authenticate({ username, password })); | ||
| const loginWithProvidedUsernamePassword = () => dispatch(authenticate({ email, password })); |
There was a problem hiding this comment.
loginWithProvidedUsernamePassword now dispatches { email, password }, so the function name is misleading. Renaming it (and any related identifiers) to reflect email/password will reduce confusion and make future maintenance/searching easier.
| const loginWithProvidedUsernamePassword = () => dispatch(authenticate({ email, password })); | |
| const loginWithProvidedEmailPassword = () => dispatch(authenticate({ email, password })); |
wfieldx
left a comment
There was a problem hiding this comment.
we don't want to revert to the v1 sdk here
No description provided.