Skip to content

Commit 542f323

Browse files
authored
Merge pull request #163 from devondragon/issue-155-Fix-inaccurate-Javadoc-on-confirmRegistration-method-on-the-UserActionController
Fix inaccurate Javadoc on confirmRegistration method and other Javadoc improvements
2 parents efe05a1 + 1fbdaa0 commit 542f323

3 files changed

Lines changed: 37 additions & 33 deletions

File tree

src/main/java/com/digitalsanctuary/spring/user/controller/UserActionController.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,13 @@ public ModelAndView showChangePasswordPage(final HttpServletRequest request, fin
8989
}
9090

9191
/**
92-
* Validate a forgot password token link from an email, and if valid, show the
93-
* registration success page.
92+
* Validates a registration token received from an email link, and if valid,
93+
* confirms the user's registration and redirects to the registration success page.
9494
*
95-
* @param request the request
96-
* @param model the model
97-
* @param token the token
98-
* @return the model and view
95+
* @param request the HTTP request
96+
* @param model the model map
97+
* @param token the verification token to validate
98+
* @return the model and view for redirection
9999
* @throws UnsupportedEncodingException the unsupported encoding exception
100100
*/
101101
@GetMapping("${user.security.registrationConfirmURI:/user/registrationConfirm}")

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

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,12 @@
3434
import lombok.extern.slf4j.Slf4j;
3535

3636
/**
37-
* Service class for managing users. It includes methods for user authentication, registration, deletion, password management, role assignment, and
38-
* related operations. This class also interacts with the user repository and session registry to perform its tasks.
37+
* Service class for managing users. Provides methods for user registration, authentication, password management, and user-related operations. This
38+
* class is transactional and uses various repositories and services for its operations.
3939
*
4040
* <p>
4141
* This class is transactional, meaning that any failure causes the entire operation to roll back to the previous state.
42-
*
43-
* @author Devon Hillard
44-
*/
45-
/**
46-
* Service class for managing users. Provides methods for user registration, authentication, password management, and user-related operations. This
47-
* class is transactional and uses various repositories and services for its operations.
42+
* </p>
4843
*
4944
* <p>
5045
* Dependencies:
@@ -112,6 +107,8 @@
112107
* <li>{@link Transactional}: Indicates that the class or methods should be transactional.</li>
113108
* <li>{@link Value}: Injects property values.</li>
114109
* </ul>
110+
*
111+
* @author Devon Hillard
115112
*/
116113
@Slf4j
117114
@Service
@@ -199,10 +196,13 @@ public String getValue() {
199196
private boolean sendRegistrationVerificationEmail;
200197

201198
/**
202-
* Register new user account.
199+
* Registers a new user account with the provided user data.
200+
* If the email already exists, throws a UserAlreadyExistException.
201+
* If sendRegistrationVerificationEmail is false, the user is enabled immediately.
203202
*
204-
* @param newUserDto the new user dto
205-
* @return the user
203+
* @param newUserDto the data transfer object containing the user registration information
204+
* @return the newly created user entity
205+
* @throws UserAlreadyExistException if an account with the same email already exists
206206
*/
207207
public User registerNewUserAccount(final UserDto newUserDto) {
208208
TimeLogger timeLogger = new TimeLogger(log, "UserService.registerNewUserAccount");
@@ -371,12 +371,15 @@ public List<String> getUsersFromSessionRegistry() {
371371
}
372372

373373
/**
374-
* Authenticates the given user without a password. The user is authenticated by loading their details, generating their authorities from their
375-
* roles and privileges, and storing these details in the security context and session. This is a potentially dangerous method to call, as it will
376-
* authenticate the user without requiring a password!!! We are using it here to allow us to authenticate a user after they have registered,
377-
* without requiring them to log in again.
374+
* Authenticates the given user without requiring a password. This method loads the user's details,
375+
* generates their authorities from their roles and privileges, and stores these details in the
376+
* security context and session.
377+
*
378+
* <p><strong>SECURITY WARNING:</strong> This is a potentially dangerous method as it authenticates
379+
* a user without password verification. This method should only be used in specific controlled scenarios,
380+
* such as after successful email verification or OAuth authentication.</p>
378381
*
379-
* @param user The user to authenticate.
382+
* @param user The user to authenticate without password verification
380383
*/
381384
public void authWithoutPassword(User user) {
382385
log.debug("UserService.authWithoutPassword: authenticating user: {}", user);

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,21 @@ public User getUserByVerificationToken(final String verificationToken) {
4343
}
4444

4545
/**
46-
* Gets the verification token.
46+
* Gets the verification token by its string value.
4747
*
48-
* @param VerificationToken the verification token
49-
* @return the verification token
48+
* @param verificationToken the verification token string
49+
* @return the verification token entity
5050
*/
51-
public VerificationToken getVerificationToken(final String VerificationToken) {
52-
return tokenRepository.findByToken(VerificationToken);
51+
public VerificationToken getVerificationToken(final String verificationToken) {
52+
return tokenRepository.findByToken(verificationToken);
5353
}
5454

5555
/**
56-
* Generate new verification token.
56+
* Generates a new verification token to replace an existing one.
57+
* Useful for extending verification periods or re-sending verification emails.
5758
*
58-
* @param existingVerificationToken the existing verification token
59-
* @return the verification token
59+
* @param existingVerificationToken the existing verification token string to replace
60+
* @return the updated verification token entity with a new token value
6061
*/
6162
public VerificationToken generateNewVerificationToken(final String existingVerificationToken) {
6263
VerificationToken vToken = tokenRepository.findByToken(existingVerificationToken);
@@ -77,10 +78,10 @@ public void createVerificationTokenForUser(final User user, final String token)
7778
}
7879

7980
/**
80-
* Validate verification token.
81+
* Validates a user verification token.
8182
*
82-
* @param token the token
83-
* @return the string
83+
* @param token the token to validate
84+
* @return the token validation result (VALID, INVALID_TOKEN, or EXPIRED)
8485
*/
8586
public UserService.TokenValidationResult validateVerificationToken(String token) {
8687
final VerificationToken verificationToken = tokenRepository.findByToken(token);

0 commit comments

Comments
 (0)