Skip to content

TECHX-7034 fixed invalid credential type#162

Open
shawn-bwell wants to merge 5 commits into
mainfrom
ss-tech-7034
Open

TECHX-7034 fixed invalid credential type#162
shawn-bwell wants to merge 5 commits into
mainfrom
ss-tech-7034

Conversation

@shawn-bwell

Copy link
Copy Markdown
Contributor

No description provided.

…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.
Copilot AI review requested due to automatic review settings April 17, 2026 18:04
@shawn-bwell
shawn-bwell requested review from a team as code owners April 17, 2026 18:04

@katekolchier katekolchier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 authenticateSdk to support SDK versions that expect different credential shapes.
  • Bump @icanbwell/bwell-sdk-ts dependency (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.

Comment thread bwell-typescript-react/src/pages/Initialize.tsx
if (!success)
return rejectWithValue(authenticationOutcome.error().message ?? "Unknown error");
return params.oauthCreds ?? params.username ?? "";
return params.oauthCreds ?? params.email ?? "";

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +24
!usernameAttempt.success() &&
usernameAttempt.error()?.message?.includes('Invalid credentials type provided')
) {
return bWellSdk.authenticate({ email: creds.email, password: creds.password } as any);
}

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
const loginWithProvidedOAuthCreds = () => dispatch(authenticate({ oauthCreds }));

const loginWithProvidedUsernamePassword = () => dispatch(authenticate({ username, password }));
const loginWithProvidedUsernamePassword = () => dispatch(authenticate({ email, password }));

Copilot AI Apr 17, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const loginWithProvidedUsernamePassword = () => dispatch(authenticate({ email, password }));
const loginWithProvidedEmailPassword = () => dispatch(authenticate({ email, password }));

Copilot uses AI. Check for mistakes.

@wfieldx wfieldx left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want to revert to the v1 sdk here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants