Skip to content

Enhance user authentication, feedback metadata, and subscription handling#3535

Merged
Baalmart merged 3 commits into
stagingfrom
oauth-setup
May 25, 2026
Merged

Enhance user authentication, feedback metadata, and subscription handling#3535
Baalmart merged 3 commits into
stagingfrom
oauth-setup

Conversation

@OchiengPaul442

@OchiengPaul442 OchiengPaul442 commented May 25, 2026

Copy link
Copy Markdown
Contributor

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done

Screenshots (optional)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added password setup prompt for OAuth-authenticated users
    • Enhanced subscription management with confirmation dialogs for subscription actions
  • Bug Fixes & Improvements

    • Updated billing checkout messaging for improved clarity
    • Improved feedback submission table formatting with better column alignment and truncation
    • Enhanced header authentication control visibility
    • Expanded social authentication availability across all environments
    • Added support for paused subscription status tracking

Review Change Stack

- Updated feedback metadata to include full URL with search parameters.
- Changed feedback platform type from 'web' to 'Analytics'.

feat: extend next-auth types for user authentication methods

- Added `authMethods` and `expiresAt` fields to User and Session interfaces in next-auth types.
- Updated JWT interface to include new fields.

feat: modify header component to conditionally show auth controls

- Introduced `showAuthControlsOnlyWhenAuthenticated` prop to Header component.
- Updated rendering logic to show auth controls based on user authentication status.

feat: add set password functionality for OAuth users

- Implemented `useSetPassword` hook for setting passwords for OAuth-authenticated users.
- Created `SetPasswordPromptDialog` component to prompt users to set a password.

feat: add password validation schema

- Added `setPasswordSchema` for validating password input during set password flow.

fix: normalize subscription status to handle 'canceled' and 'paused'

- Updated `normalizeStatus` function to recognize 'canceled' as a valid status.
- Added 'paused' status to subscription handling.

feat: enhance user service with set password endpoint

- Implemented `setPassword` method in UserService for updating passwords.
- Added error handling for password setting process.

chore: update API types for new password functionality

- Added `SetPasswordRequest` and `SetPasswordResponse` interfaces to API types.
- Updated User interface to include `authMethods`.

refactor: improve OAuth session handling with auth methods

- Enhanced OAuth session and profile handling to include `authMethods`.
- Updated session management to reflect changes in user authentication methods.
@OchiengPaul442 OchiengPaul442 self-assigned this May 25, 2026
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@OchiengPaul442, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 38 minutes and 58 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f9e2b55-0f1d-4098-a71a-468135faec2b

📥 Commits

Reviewing files that changed from the base of the PR and between 0768215 and bf3096d.

📒 Files selected for processing (2)
  • src/platform/src/modules/feedback/components/FeedbackLauncher.tsx
  • src/platform/src/shared/components/auth/SetPasswordPromptDialog.tsx
📝 Walkthrough

Walkthrough

This PR introduces a comprehensive authentication methods tracking system for OAuth users, adds password-setting capability via a prompt dialog, refactors subscription management with dialog-driven confirmations, and improves various UI components with updated copy, routing logic, and table layout.

Changes

Authentication Methods System & Password Management

Layer / File(s) Summary
Auth method types and validation schemas
src/platform/src/shared/types/api.ts, src/platform/src/shared/lib/validators.ts, src/platform/src/shared/types/global.d.ts, src/platform/src/next-auth.d.ts
Defines AuthMethods interface with provider-specific boolean flags, password-setting request/response types, and Zod validation enforcing 6–30 character passwords with at least one letter and number; adds authMethods to NextAuth User/Session/JWT interfaces.
NextAuth JWT and session callbacks
src/platform/src/shared/lib/auth.ts
Updates jwt callback to normalize and store authMethods from authenticated users and session updates; session callback computes normalized authMethods from token and attaches to session and session.user.
OAuth authMethods propagation
src/platform/src/shared/lib/oauth-session.ts
Extends OAuth profile/session interfaces with optional authMethods fields; adds normalizeAuthMethods() helper; updates buildSessionFromProfile() and verifyBackendOAuthSession() to propagate normalized authMethods through OAuth flows.
Password service and hook
src/platform/src/shared/services/userService.ts, src/platform/src/shared/hooks/useUser.ts, src/platform/src/shared/hooks/index.ts
Adds UserService.setPassword() method posting to /users/setPassword endpoint with error normalization; exports useSetPassword SWR hook wrapping the service call.
SetPasswordPromptDialog component
src/platform/src/shared/components/auth/SetPasswordPromptDialog.tsx
Renders "Add a password" dialog for authenticated OAuth users without password auth method; uses sessionStorage to remember "Not now" dismissals; manages password form with React Hook Form + Zod; calls service on submit, updates session authMethods, and shows contextual toasts.
Auth provider integration
src/platform/src/shared/providers/auth-provider.tsx
Extends public auth routes with /request-organization alongside /org-invite; introduces isAuthenticatedAccessiblePublicRoute to allow authenticated users to bypass redirects; injects SetPasswordPromptDialog into UserDataFetcher.

Header Conditional Auth Controls & Routing

Layer / File(s) Summary
Header authentication-conditional controls
src/platform/src/shared/components/header/index.tsx, src/platform/src/shared/components/header/types/index.ts
Adds showAuthControlsOnlyWhenAuthenticated prop to Header; uses useSession() to gate OrganizationSelector and ProfileDropdown visibility based on authenticated status; updates HeaderProps interface.
MainLayout and RequestOrganizationLayout
src/platform/src/shared/layouts/MainLayout.tsx, src/platform/src/app/(dashboard)/request-organization/layout.tsx
MainLayout adds showHeaderAuthControlsOnlyWhenAuthenticated prop (default false) and forwards to Header; RequestOrganizationLayout passes true alongside showSidebar={false}.
SocialAuthSection domain-check removal
src/platform/src/shared/components/auth/SocialAuthSection.tsx
Removes staging/local/test hostname checks and conditional shouldShowSocialAuth logic; simplifies to unconditional rendering; initializes lastUsedProvider state directly on mount.
Middleware matcher update
src/platform/middleware.ts
Removes specific /org-invite matcher entry, keeping only /user/:path\* and /org/:path\* wildcard matchers.

Billing & Subscription UI Refactor

Layer / File(s) Summary
Subscription status types and normalization
src/platform/src/shared/types/api.ts, src/platform/src/shared/services/subscriptionService.ts
Extends UserSubscription.status and response payload status unions to include 'paused'; updates normalizeStatus() to handle both American/British cancelled spellings.
CheckoutDialog copy and labels
src/platform/src/modules/billing/components/CheckoutDialog.tsx
Updates subtitle to render plan name/currency/price with /monthly suffix or fallback message; changes "Selected Plan" → "Plan To Activate"; rewrites secure-checkout explanatory text; changes heading to "Plan highlights".
BillingPage messaging
src/platform/src/modules/billing/BillingPage.tsx
Updates checkout status messages to "Checkout completed…" and "Checkout was closed before confirmation…"; updates section heading to "API Subscription & Billing" with revised description.
SubscriptionSection dialog confirmation flow
src/platform/src/modules/billing/components/SubscriptionSection.tsx
Introduces pendingConfirmation/runningAction state; refactors enable/disable/cancel handlers to set pending state instead of direct execution; clears state in handler finally blocks; updates toast messages and card styling; adds statusNotice memo for contextual notices on past_due/cancelled/paused/renewal-off conditions; refactors per-plan action labels.

Feedback Table & Analytics Updates

Layer / File(s) Summary
Feedback table column layout improvements
src/platform/src/app/(dashboard)/system/feedback/page.tsx
"Subject" now renders as single truncated text with tooltip instead of two-line layout; adds minWidth, maxWidth, and whitespace-nowrap to "Status", "Rating", "Email", "Submitted", and "Actions" columns; truncates email with tooltip; formats timestamp via formatDateTime().
Feedback launcher metadata and platform
src/platform/src/modules/feedback/components/FeedbackLauncher.tsx
Updates page metadata to include full URL (pathname + search) instead of pathname alone; changes platform field from 'web' to 'Analytics'.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • #3509: Middleware matcher updates for /user/:path* routes align with OAuth redirect/rewrite behavior and authenticated user routing logic introduced in this PR.

Possibly related PRs

  • airqo-platform/AirQo-frontend#3527: Both PRs modify SocialAuthSection.tsx's hostname-based rendering logic (PR #3527 adds gating; this PR removes staging early-return so social auth always renders).
  • airqo-platform/AirQo-frontend#3501: Directly tied—this PR refactors SocialAuthSection component hostname checks, which relates to PR #3501's OAuth "last used" provider utilities.
  • airqo-platform/AirQo-frontend#3500: Both PRs refactor SubscriptionSection.tsx handlers and subscription-service method interaction for auto-renew/cancel flows.

Suggested labels

authentication, billing, work in progress

Suggested reviewers

  • Baalmart
  • Codebmk

🔐 OAuth users now add passwords with a friendly prompt,
💳 Subscriptions now confirm before they're swapped,
🎯 Headers know when you're logged in—auth controls fit,
📊 Feedback tables got styling to help things click. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the three main enhancement areas covered by the changeset: user authentication (new set-password flow, auth methods tracking), feedback metadata (URL with search params), and subscription handling (status normalization, UI improvements).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oauth-setup

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/platform/src/shared/lib/auth.ts (1)

100-135: ⚡ Quick win

Extract normalizeAuthMethods into a shared helper used by both auth flows.

This normalization logic is duplicated in src/platform/src/shared/lib/oauth-session.ts. A single shared utility avoids provider-key drift and keeps token/session behavior consistent.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/platform/src/shared/lib/auth.ts` around lines 100 - 135, Move the
duplicated normalizeAuthMethods logic (and AUTH_METHOD_KEYS) into a single
exported helper module and have both usages import it: create a shared function
(exported) that returns AuthMethods | undefined and reuse it from the existing
callers (e.g., where normalizeAuthMethods is currently declared and in
oauth-session.ts), ensure the helper exports or reuses the AuthMethods type,
keep the exact boolean mapping for keys
('password','google','github','linkedin','microsoft','twitter','facebook','apple'),
and replace the local implementations with an import of the shared
normalizeAuthMethods to avoid drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/platform/src/modules/feedback/components/FeedbackLauncher.tsx`:
- Around line 78-79: The metadata's `page` value (built from
window.location.pathname + window.location.search) can go stale because it's
computed inside a useMemo that only depends on `pathname`; update the code in
FeedbackLauncher so `page` is recomputed at submit time instead of relying on
the memo: leave the existing metadata useMemo for stable fields (e.g., browser
via getBrowserLabel()) but remove or stop reading the cached `page` there, and
in the submit handler (the function that sends/creates feedback) construct the
`page` value afresh from window.location.pathname + window.location.search and
attach it to the metadata payload you send; alternatively, if you prefer a memo,
include window.location.search (or a derived `search` variable) in the useMemo
dependency array so `page` updates on query-only changes.
- Around line 78-79: The metadata.page value in FeedbackLauncher.tsx currently
forwards the full query string and must be sanitized before persisting; update
the code that sets metadata.page to parse window.location.search, remove or
redact sensitive keys (e.g., code, state, token, access_token, refresh_token,
id_token, session, auth, nonce, secret) and then rebuild the pathname+safe query
(or omit the query if empty) so only non-sensitive params are included; locate
the metadata construction in the FeedbackLauncher component (the metadata.page
assignment) and replace it with a sanitized URL generation step that uses
URLSearchParams to filter out the listed keys and produce the final page value.

In `@src/platform/src/shared/components/auth/SetPasswordPromptDialog.tsx`:
- Around line 133-147: The flow in markPasswordAsConfigured conflates failures
from update() (session/authMethods persistence) with the password-save result,
causing misleading toasts and repeated prompts; change markPasswordAsConfigured
to call update() in a try/catch so that if update() fails you log/emit a
session-update specific error (or show a distinct toast) but still treat the
password as successfully configured (proceed to remove dismissStorageKey and
setIsOpen(false)); reference the markPasswordAsConfigured function, the update()
call, sessionStorage.removeItem(dismissStorageKey) and setIsOpen(false) when
implementing the change so failures in update() do not cause the UI to indicate
password save failed.

---

Nitpick comments:
In `@src/platform/src/shared/lib/auth.ts`:
- Around line 100-135: Move the duplicated normalizeAuthMethods logic (and
AUTH_METHOD_KEYS) into a single exported helper module and have both usages
import it: create a shared function (exported) that returns AuthMethods |
undefined and reuse it from the existing callers (e.g., where
normalizeAuthMethods is currently declared and in oauth-session.ts), ensure the
helper exports or reuses the AuthMethods type, keep the exact boolean mapping
for keys
('password','google','github','linkedin','microsoft','twitter','facebook','apple'),
and replace the local implementations with an import of the shared
normalizeAuthMethods to avoid drift.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 49667b66-791e-44f6-a4a3-853311aecb72

📥 Commits

Reviewing files that changed from the base of the PR and between 05247eb and 0768215.

📒 Files selected for processing (23)
  • src/platform/middleware.ts
  • src/platform/src/app/(dashboard)/request-organization/layout.tsx
  • src/platform/src/app/(dashboard)/system/feedback/page.tsx
  • src/platform/src/modules/billing/BillingPage.tsx
  • src/platform/src/modules/billing/components/CheckoutDialog.tsx
  • src/platform/src/modules/billing/components/SubscriptionSection.tsx
  • src/platform/src/modules/feedback/components/FeedbackLauncher.tsx
  • src/platform/src/next-auth.d.ts
  • src/platform/src/shared/components/auth/SetPasswordPromptDialog.tsx
  • src/platform/src/shared/components/auth/SocialAuthSection.tsx
  • src/platform/src/shared/components/header/index.tsx
  • src/platform/src/shared/components/header/types/index.ts
  • src/platform/src/shared/hooks/index.ts
  • src/platform/src/shared/hooks/useUser.ts
  • src/platform/src/shared/layouts/MainLayout.tsx
  • src/platform/src/shared/lib/auth.ts
  • src/platform/src/shared/lib/oauth-session.ts
  • src/platform/src/shared/lib/validators.ts
  • src/platform/src/shared/providers/auth-provider.tsx
  • src/platform/src/shared/services/subscriptionService.ts
  • src/platform/src/shared/services/userService.ts
  • src/platform/src/shared/types/api.ts
  • src/platform/src/shared/types/global.d.ts
💤 Files with no reviewable changes (1)
  • src/platform/src/shared/components/auth/SocialAuthSection.tsx

Comment thread src/platform/src/modules/feedback/components/FeedbackLauncher.tsx Outdated
Comment thread src/platform/src/shared/components/auth/SetPasswordPromptDialog.tsx Outdated
@github-actions

Copy link
Copy Markdown
Contributor

New azure analytics_platform changes available for preview here

@Baalmart
Baalmart merged commit 5d88598 into staging May 25, 2026
19 of 20 checks passed
@Baalmart
Baalmart deleted the oauth-setup branch May 25, 2026 12:22
@Baalmart Baalmart mentioned this pull request May 25, 2026
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants