Skip to content

Fix : No protected route can be accessed via direct url without signin#349

Merged
calvadev merged 4 commits intoshopstr-eng:mainfrom
Aryan0699:fix/signin
Apr 7, 2026
Merged

Fix : No protected route can be accessed via direct url without signin#349
calvadev merged 4 commits intoshopstr-eng:mainfrom
Aryan0699:fix/signin

Conversation

@Aryan0699
Copy link
Copy Markdown
Contributor

Description

It solves the auth-gap where protected pages were accessible via direct URL when logged out.
It introduces a reusable route guard and applies it consistently across all private routes .

  • Added a shared guard hook in components/hooks/use-auth-guard.ts.
  • Guard behavior:
    • Reads auth state from SignerContext.
    • Opens SignInModal for logged-out users.
    • Redirects to /marketplace when modal is dismissed.

Applied guard to all protected pages:

  • pages/settings/index.tsx
  • pages/settings/user-profile.tsx
  • pages/settings/shop-profile.tsx
  • pages/settings/community.tsx
  • pages/settings/preferences.tsx
  • pages/settings/nwc.tsx
  • pages/wallet/index.tsx
  • pages/orders/index.tsx
  • pages/cart/index.tsx
  • pages/order-summary/index.tsx
  • pages/my-listings/index.tsx

Resolved or fixed issue

Fixes #343

Screenshots (if applicable)

Before

Screenshot from 2026-04-05 22-43-49

After

image

Affirmation

Copilot AI review requested due to automatic review settings April 5, 2026 20:14
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 5, 2026

@Aryan0699 is attempting to deploy a commit to the shopstr-eng Team on Vercel.

A member of the Team first needs to authorize it.

@Aryan0699
Copy link
Copy Markdown
Contributor Author

@GautamBytes Should i also include tests for these ?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR closes the “auth gap” where protected pages could be accessed directly while logged out by introducing a shared auth-guard hook and wiring it into private routes to prompt sign-in and redirect on dismiss.

Changes:

  • Added a reusable useAuthGuard hook to centralize “logged out → open SignInModal → redirect to /marketplace” behavior.
  • Updated multiple protected pages to block rendering when logged out and instead show SignInModal.
  • Removed direct SignerContext usage in at least one page in favor of the shared guard hook.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
components/hooks/use-auth-guard.ts Introduces the shared guard hook that opens the sign-in modal and redirects on dismiss.
pages/wallet/index.tsx Applies the guard and blocks the wallet UI behind the sign-in modal.
pages/settings/index.tsx Applies the guard to the settings landing page.
pages/settings/user-profile.tsx Applies the guard to user-profile settings.
pages/settings/shop-profile.tsx Applies the guard to shop-profile settings.
pages/settings/preferences.tsx Applies the guard to preferences settings.
pages/settings/nwc.tsx Applies the guard to NWC settings.
pages/settings/community.tsx Applies the guard to the community management page.
pages/orders/index.tsx Applies the guard to the orders/messages view.
pages/order-summary/index.tsx Applies the guard and removes direct SignerContext usage.
pages/cart/index.tsx Applies the guard to the cart page.
pages/my-listings/index.tsx Applies the guard to the my-listings page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pages/wallet/index.tsx Outdated
Comment thread components/hooks/use-auth-guard.ts Outdated
Comment thread pages/settings/index.tsx Outdated
@GautamBytes
Copy link
Copy Markdown
Contributor

  • The new guard is treating the initial auth-loading state as logged out, so a real signed-in user opening a protected page directly can still get the sign-in modal/redirect before hydration finishes.
  • Also, /settings/api-keys is still outside the shared ProtectedRoute coverage, so please wrap that page too if the goal is to cover all private routes consistently.

@Aryan0699
Copy link
Copy Markdown
Contributor Author

Aryan0699 commented Apr 6, 2026

Thanks for pointing that out , will have a look into it and will soon get it resolved 👍

@Aryan0699
Copy link
Copy Markdown
Contributor Author

Aryan0699 commented Apr 6, 2026

This works right ?

  • If auth state is not resolved yet, isGuarded is false. ( In this there can be a chance that he may be able to see but that wont happen since components/utility-components/protected-route.tsx checks isAuthResolved first. If unresolved, it returns a dic container with just black bg, not children).
  • If auth is resolved and user is logged in, isGuarded is false.
  • If auth is resolved and user is logged out, isGuarded is true.

@Aryan0699
Copy link
Copy Markdown
Contributor Author

Done

@GautamBytes
Copy link
Copy Markdown
Contributor

LGTM Now!!

@Aryan0699
Copy link
Copy Markdown
Contributor Author

Aryan0699 commented Apr 6, 2026

Hi Gautam, just wanted to clairfy
currently the trust button appears after the all the products are loaded and if the products continue to load it might not be visible for a long time
Is this the intended behaviour , I guess it needs a fix ?

@GautamBytes
Copy link
Copy Markdown
Contributor

behaviour , I guess it needs a fix ?

yes u can raise a separate pr for this

@calvadev calvadev merged commit 41565d7 into shopstr-eng:main Apr 7, 2026
1 check failed
@Aryan0699 Aryan0699 changed the title fix : No protected route can be accessed via direct url without signin Fix : No protected route can be accessed via direct url without signin Apr 9, 2026
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.

4 participants