Skip to content

Commit 27fcf6e

Browse files
committed
fix: remove dead code and document passwordless endpoint requirements
Simplify unreachable ternary in registerNewUserAccount — the null guard already throws before line 275, so the null branch can never execute. Add JavaDoc note that /user/registration/passwordless must be in unprotectedURIs for deny-by-default apps. Add local testing workflow with demo app to CLAUDE.md including playwright-test profile requirement.
1 parent e0a3fe7 commit 27fcf6e

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

CLAUDE.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,40 @@ Spring User Framework is a reusable Spring Boot library (not an application) tha
3434
./gradlew publishLocal
3535
```
3636

37+
## Local Testing with Demo App
38+
39+
The [SpringUserFrameworkDemoApp](https://github.com/devondragon/SpringUserFrameworkDemoApp) is a Spring Boot app that consumes this library for testing and demonstration. It is typically checked out alongside this repo at `../SpringUserFrameworkDemoApp`.
40+
41+
### Workflow
42+
43+
1. **Publish the library locally:**
44+
```bash
45+
./gradlew publishLocal
46+
```
47+
This publishes the current SNAPSHOT version (from `gradle.properties`) to your local Maven repository.
48+
49+
2. **Update the demo app dependency** (if needed):
50+
In `../SpringUserFrameworkDemoApp/build.gradle`, ensure the dependency version matches the SNAPSHOT:
51+
```groovy
52+
implementation 'com.digitalsanctuary:ds-spring-user-framework:X.Y.Z-SNAPSHOT'
53+
```
54+
Check `gradle.properties` for the current version.
55+
56+
3. **Start the demo app:**
57+
```bash
58+
cd ../SpringUserFrameworkDemoApp
59+
./gradlew bootRun --args='--spring.profiles.active=local,playwright-test'
60+
```
61+
The app runs on `http://localhost:8080` by default. The `playwright-test` profile activates `TestDataController` and `TestApiSecurityConfig`, which the Playwright tests require for test data setup/teardown. Omit `playwright-test` if only doing manual browser testing.
62+
63+
4. **Run Playwright tests:**
64+
```bash
65+
cd ../SpringUserFrameworkDemoApp/playwright
66+
npx playwright test --project=chromium
67+
```
68+
69+
5. **Manual browser testing** can be done with Playwright MCP tools or directly in Chrome at `http://localhost:8080`.
70+
3771
## Architecture
3872

3973
### Package Structure

src/main/java/com/digitalsanctuary/spring/user/api/UserAPI.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ public ResponseEntity<JSONResponse> getAuthMethods(@AuthenticationPrincipal DSUs
380380
/**
381381
* Registers a new passwordless user account (passkey-only).
382382
*
383+
* <p><strong>Note:</strong> Consuming applications using {@code user.security.defaultAction: deny}
384+
* must add {@code /user/registration/passwordless} to their {@code user.security.unprotectedURIs}
385+
* configuration to allow unauthenticated access to this endpoint.
386+
*
383387
* @param dto the passwordless registration DTO
384388
* @param request the HTTP servlet request
385389
* @return a ResponseEntity containing a JSONResponse with the registration result

src/main/java/com/digitalsanctuary/spring/user/service/UserService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public User registerNewUserAccount(final UserDto newUserDto) {
272272
User user = new User();
273273
user.setFirstName(newUserDto.getFirstName());
274274
user.setLastName(newUserDto.getLastName());
275-
user.setPassword(newUserDto.getPassword() != null ? passwordEncoder.encode(newUserDto.getPassword()) : null);
275+
user.setPassword(passwordEncoder.encode(newUserDto.getPassword()));
276276
user.setEmail(newUserDto.getEmail().toLowerCase());
277277
user.setRoles(Arrays.asList(roleRepository.findByName(USER_ROLE_NAME)));
278278

0 commit comments

Comments
 (0)