Skip to content

Show guest account screens in a minimal layout when the store is not open to guests - #1084

Merged
KrzysztofPajak merged 7 commits into
developfrom
feature/storefront-auth-layout
Nov 22, 2026
Merged

KrzysztofPajak merged 7 commits into
developfrom
feature/storefront-auth-layout

Conversation

@KrzysztofPajak

@KrzysztofPajak KrzysztofPajak commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Resolves: no issue, the problem is described below
Type: feature

Issue

If a store is open to registered customers only (Guests lose the "Public store. Allow navigation" permission), or the store is closed, guests are sent to /login. That page renders inside the full storefront layout, so a guest still sees the store's content: the search box lists the categories, the footer lists CMS pages and links to blog, news, knowledge base and new products, and the newsletter box and promo block are rendered. View components do not go through the PublicStore filter, and only the menu checks the permission itself.

To reproduce: remove "Public store. Allow navigation" from Guests, then open the store in a private window. You are redirected to /login, which shows the category drop-down in the search box and the footer links.

Solution

The guest-reachable screens keep their URLs, actions and views. When the visitor may not browse the store, they render in a new minimal layout instead of _SingleColumn, similar to the admin login page: theme styles, logo, language selector, cookie consent and the form. The header, menu, search box, footer and content widget zones are not rendered.

  • IStoreAccessService (Grand.Web.Common.Security.Authorization) returns StoreAccess for the customer of the request:
    • Closed: the store is closed and the customer has no AccessClosedStore.
    • RegisteredOnly: the customer has no PublicStoreAllowNavigation.
    • Open: everyone else.
  • Views/Shared/_GuestAccount.cshtml asks the service and renders as _SingleColumn (Open) or _LayoutAuth (otherwise). Login, register, register result, password recovery and confirm, account activation, two-factor and the OIDC link and failure views set Layout = "_GuestAccount"; StoreClosed always uses _LayoutAuth. View models and controllers are unchanged, so a new guest screen only needs the layout name.
  • _LayoutAuth keeps the head_html_tag, body_start_html_tag_after and body_end_html_tag_before zones, which carry scripts such as analytics and consent.
  • The login page hides the register, password recovery and guest order links in a closed store (those actions redirect to Store closed; staff still sign in with the form or SSO), and shows the guest order link only when the store is open to guests, because the guest order pages need navigation.
  • TwoFactorAuthorization (GET and POST) gets [PublicStore(true)] and [ClosedStore(true)] like Login. Before, a customer with two-factor sign-in on was sent back to /login or to Store closed after the password step.
  • SetLanguage gets [ClosedStore(true)], so the language selector works on the sign-in screens of a closed store.
  • No new CSS and no bundle rebuild: the layout uses Bootstrap utility classes the theme bundles already ship.

Known limits, left for separate PRs:

  • The Facebook and Google plugin "sign-in failed" views still use _SingleColumn.
  • A theme that overrides one of these account views keeps its own Layout line until it switches to _GuestAccount. Modern and Nordic do not override them.

Breaking changes

None intended. The two-factor step and the language switch are now reachable by guests of a closed or registered-only store, as the login page already was. Behavior for a store open to guests is unchanged.

Testing

  1. dotnet test src/Tests/Grand.Web.Common.Tests and dotnet test src/Tests/Grand.Web.Tests pass. New tests: StoreAccessServiceTests (4) and StoreAccessAttributeTests (two-factor actions and SetLanguage carry the exemptions).
  2. Admin → Access control: remove "Public store. Allow navigation" from Guests, then restart the app, because permissions are cached.
  3. In a private window open /. It redirects to /login, which shows the logo, the language selector and the form. The page source has no search-box, no <footer> and no guest order link. /register and /passwordrecovery look the same.
  4. Submit a wrong password. The page re-renders with the error and stays in the minimal layout.
  5. With two-factor sign-in on for a customer, sign in: the code screen opens in the minimal layout instead of looping back to /login.
  6. Give Guests the permission back. /login shows the full layout as before.
  7. Settings → General → Store closed: on, then restart. As a guest, / redirects to /storeclosed (minimal layout). /login shows the form without the register, forgot-password and guest-order links, /register redirects to /storeclosed, and /changelanguage/{code}?returnUrl=/login returns to /login.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 16:00

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

support added 3 commits November 22, 2026 17:23
The value no longer rides on nine view models through a result filter. The guest account
views use _GuestAccount, which asks IStoreAccessService and renders as _SingleColumn or
_LayoutAuth; Login reads the same service to hide links. Nothing defaults to Open when a
filter is missed or a model goes out as JSON, the two-factor step renders without a
model again, and a new guest screen needs only the layout name.
…open

TwoFactorAuthorization had neither [PublicStore(true)] nor [ClosedStore(true)], so a
customer with two-factor sign-in on was sent back to Login (registered-only store) or
to Store closed after entering the password. SetLanguage was blocked on a closed store,
so the language selector on the sign-in screens did nothing.
They carry scripts such as analytics and consent, not catalog content; _LayoutPopup keeps
them too. Without them sign-in and Store closed pages sent no analytics on stores that
use the minimal layout.
@KrzysztofPajak
KrzysztofPajak merged commit 3b865f7 into develop Nov 22, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the feature/storefront-auth-layout branch November 22, 2026 18:06
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.

2 participants