Skip to content

Panels: keep the two-factor step on the panel after a password sign-in - #911

Open
KrzysztofPajak wants to merge 2 commits into
developfrom
fix/panel-two-factor-session
Open

KrzysztofPajak wants to merge 2 commits into
developfrom
fix/panel-two-factor-session

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Resolves: no issue (found while reviewing the provider-only sign-in mode, #907-#910)
Type: bugfix

Issue

A password sign-in on the Admin, Store or Vendor panel that needs a second factor left the panel:

  • BaseLoginController.Index stored the storefront's session key RequiresTwoFactor and redirected to the storefront's TwoFactorAuthorization route.
  • The code was entered on the storefront page, which signed the user in and sent them to the storefront home page instead of the panel.
  • The panels' own TwoFactorAuthorization actions (GET and POST) read AdminRequiresTwoFactor, which nothing set, so the panel two-factor views were unreachable.

To reproduce on develop: enable two-factor authentication in the customer settings, enable it for an administrator, sign in at /admin/login with the password. The browser lands on /twofactorauthorization of the storefront, and after the code on the storefront home page.

Solution

  • The panel keeps its own session key (TwoFactorSessionKey, the existing AdminRequiresTwoFactor value) and redirects to its own Login/TwoFactorAuthorization action in the current area (/admin/..., /store/..., /vendor/...).
  • After a valid code the user is signed in and lands on the panel's home page (AdminIndex, StoreIndex, VendorIndex), as after a password sign-in without a second factor.
  • A POST to the panel's two-factor action without the password step returns to the panel's login page instead of the storefront home page.
  • Tests: LoginControllerTwoFactorTests (password step → panel second step, form shown, valid code signs in to the panel, wrong code does not, no password step → panel login).

Verified end to end on a running copy with a two-factor (app verification) administrator: /admin/login → /Admin/Login/TwoFactorAuthorization; a wrong code stays on the form; a valid TOTP code opens the dashboard.

Breaking changes

None. The storefront's two-factor flow is unchanged.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 12:13

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 reached their quota limit.

A panel password sign-in that needs a second factor stored the storefront's session key and redirected to the storefront's two-factor page, so the code was entered on the storefront and the user ended up there; the panels' own two-factor action read a key nobody set. The panel now keeps its own key and sends the user to its own TwoFactorAuthorization action (Admin, Store and Vendor).
@KrzysztofPajak
KrzysztofPajak force-pushed the fix/panel-two-factor-session branch from a9c018e to 6b5cc3a Compare October 14, 2026 16:21
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