Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix authentication-patterns guide: parenthesize the combined-strategy format check so `(request.format ?: "html") == "json"` evaluates correctly; the unparenthesized form crashed at runtime when `request.format` was set. Also corrects the `hasStrategy` rationale — `registerStrategy()` replaces in place so duplicates cannot stack; the guard skips rebuilding the strategy object on warm reloads (#3116).
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ local.di.map("sessionStrategy").to("wheels.auth.SessionStrategy").asSingleton();

Both are singletons — one instance per app lifetime. The authenticator holds its strategy registry in instance state, so a singleton is the correct scope.

Wire the session strategy into the authenticator on app init. A cold reload registers it once; the `hasStrategy` check keeps a second reload from stacking duplicates:
Wire the session strategy into the authenticator on app init. `registerStrategy()` replaces any existing entry with the same name in place, so duplicate registrations cannot stack. The `hasStrategy` guard simply skips rebuilding the strategy object on warm reloads:

```cfm {test:compile} title="config/app.cfm or equivalent init hook"
if (StructKeyExists(application, "wheelsdi") && application.wheelsdi.containsInstance("authenticator")) {
Expand Down Expand Up @@ -340,7 +340,7 @@ component extends="wheels.Controller" {
private function authenticate() {
var result = service("authenticator").authenticate(request);
if (!result.success) {
if (request.format ?: "html" == "json") {
if ((request.format ?: "html") == "json") {
renderWith(data={error: result.error}, status=result.statusCode);
} else {
flashInsert(error="Please log in first");
Expand Down
Loading