Skip to content

Commit aa1cc50

Browse files
dfcoffinclaude
andcommitted
fix(#175): error-page links + Enabled account toggle
- Error pages (404 error.html, 400, 403): "Go Home"/"Login" used host-absolute hrefs that bypassed the /DataCustodian context path (dead links) -> context- relative th:href. Removed their duplicate bottom Bootstrap <script>/icons (now provided once by the head fragment; double-loading broke the navbar dropdown). Browser-rendered HTML error page link targets all verified 200 (API clients still get a JSON error via content negotiation, as before). - Accounts were always "Enabled = Yes" with no way to change it. Added an Enabled switch to the user-account form; update() persists it. A disabled account now shows "No" in the list and cannot sign in. datacustodian suite: 160 tests, 0 failures. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 041adfc commit aa1cc50

5 files changed

Lines changed: 12 additions & 22 deletions

File tree

‎openespi-datacustodian/src/main/java/org/greenbuttonalliance/espi/datacustodian/web/custodian/RetailCustomerController.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ public String update(@PathVariable Long retailCustomerId,
141141
if (form.getRole() != null && !form.getRole().isBlank()) {
142142
existing.setRole(form.getRole());
143143
}
144+
// Checkbox bound via th:field renders a hidden field, so a non-null value always arrives;
145+
// default to enabled if somehow absent.
146+
existing.setEnabled(form.getEnabled() != null ? form.getEnabled() : Boolean.TRUE);
144147
if (form.getPassword() != null && !form.getPassword().isBlank()) {
145148
existing.setPassword(customerPasswordEncoder.encode(form.getPassword()));
146149
}

‎openespi-datacustodian/src/main/resources/templates/custodian/retailcustomers/form.html‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ <h2 class="mt-4" th:text="${editMode} ? 'Edit User Account' : 'New User Account'
4141
<option value="ROLE_CUSTODIAN">Administrator (Custodian)</option>
4242
</select>
4343
</div>
44+
<div class="form-check form-switch mb-3">
45+
<input type="checkbox" id="enabled" class="form-check-input" role="switch"
46+
th:field="*{enabled}"/>
47+
<label for="enabled" class="form-check-label">Enabled (account may sign in)</label>
48+
</div>
4449
<div class="mb-3">
4550
<label for="password" class="form-label">Password</label>
4651
<input type="password" id="password" class="form-control"

‎openespi-datacustodian/src/main/resources/templates/error.html‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h6>Error Details:</h6>
3434
</div>
3535

3636
<div class="d-flex justify-content-center gap-3 mt-4">
37-
<a href="/" class="btn btn-primary">Go Home</a>
37+
<a th:href="@{/}" class="btn btn-primary">Go Home</a>
3838
<button onclick="history.back()" class="btn btn-outline-secondary">Go Back</button>
3939
<button onclick="location.reload()" class="btn btn-outline-info">Try Again</button>
4040
</div>
@@ -43,11 +43,5 @@ <h6>Error Details:</h6>
4343

4444
<footer th:replace="~{fragments/layout :: footer}"></footer>
4545
</div>
46-
47-
<!-- Bootstrap JS -->
48-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
49-
50-
<!-- Bootstrap Icons -->
51-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
5246
</body>
5347
</html>

‎openespi-datacustodian/src/main/resources/templates/error/400.html‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,13 @@ <h2 class="mb-4">Bad Request</h2>
1919
The request could not be understood by the server due to malformed syntax.
2020
</p>
2121
<div class="d-flex justify-content-center gap-3">
22-
<a href="/" class="btn btn-primary">Go Home</a>
22+
<a th:href="@{/}" class="btn btn-primary">Go Home</a>
2323
<button onclick="history.back()" class="btn btn-outline-secondary">Go Back</button>
2424
</div>
2525
</div>
2626
</div>
2727

2828
<footer th:replace="~{fragments/layout :: footer}"></footer>
2929
</div>
30-
31-
<!-- Bootstrap JS -->
32-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
33-
34-
<!-- Bootstrap Icons -->
35-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
3630
</body>
3731
</html>

‎openespi-datacustodian/src/main/resources/templates/error/403.html‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,14 @@ <h2 class="mb-4">Access Forbidden</h2>
1919
You don't have permission to access this resource. Please contact your administrator if you believe this is an error.
2020
</p>
2121
<div class="d-flex justify-content-center gap-3">
22-
<a href="/" class="btn btn-primary">Go Home</a>
23-
<a href="/login" class="btn btn-outline-primary">Login</a>
22+
<a th:href="@{/}" class="btn btn-primary">Go Home</a>
23+
<a th:href="@{/login}" class="btn btn-outline-primary">Login</a>
2424
<button onclick="history.back()" class="btn btn-outline-secondary">Go Back</button>
2525
</div>
2626
</div>
2727
</div>
2828

2929
<footer th:replace="~{fragments/layout :: footer}"></footer>
3030
</div>
31-
32-
<!-- Bootstrap JS -->
33-
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
34-
35-
<!-- Bootstrap Icons -->
36-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
3731
</body>
3832
</html>

0 commit comments

Comments
 (0)