Skip to content
Merged
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
Expand Up @@ -76,7 +76,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti
"/api/v1/auth/forgot-password", "/api/v1/auth/reset-password",
"/api/v1/auth/refresh-token")
.permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/auth/activate")
.requestMatchers(HttpMethod.GET, "/api/v1/auth/activate-account")
.permitAll()
.requestMatchers("/swagger-ui/**", "/v3/api-docs/**", "/actuator/health")
.permitAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public ResponseEntity<ApiResponse<Map<String, Object>>> tokenInfo(
return ResponseEntity.ok(ApiResponse.success(claims, "Token claims retrieved successfully"));
}

@GetMapping("/activate")
@GetMapping("/activate-account")
public ResponseEntity<ApiResponse<UserResponse>> activate(@RequestParam String token) {
return ResponseEntity.ok(ApiResponse.success(userService.activate(token), "Account activated successfully"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.edgareldy.springboottutorial.validation.password.PasswordsMatch;
import com.edgareldy.springboottutorial.validation.password.ValidPassword;
import com.edgareldy.springboottutorial.validation.unique.Unique;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
Expand All @@ -24,10 +25,10 @@
public record RegisterRequest(

@NotBlank(message = "First name must not be blank")
String firstName,
@JsonProperty("first_name") String firstName,

@NotBlank(message = "Last name must not be blank")
String lastName,
@JsonProperty("last_name") String lastName,

@NotBlank(message = "Username must not be blank")
@Size(min = 3, max = 50, message = "Username must be between 3 and 50 characters")
Expand All @@ -46,7 +47,7 @@ public record RegisterRequest(
String password,

@NotBlank(message = "Password confirmation must not be blank")
String confirmPassword
@JsonProperty("confirm_password") String confirmPassword
) {

// Overrides the compiler-generated toString(): LoggingAspect logs every
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public EmailServiceImpl(JavaMailSender mailSender,
@Override
@Async("emailTaskExecutor")
public void sendActivationEmail(AppUser user, String token) {
String link = frontendUrl + "/auth/activate?token=" + token;
String link = frontendUrl + "/auth/activate-account?token=" + token;
Context context = new Context(Locale.ENGLISH);
context.setVariable("username", user.getUsername());
context.setVariable("activationLink", link);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ void _08_ShouldReturn200_WhenActivationTokenValid() throws Exception {
List.of(new RoleResponse(1L, "USER", List.of())));
when(userService.activate("valid-token")).thenReturn(activated);

mockMvc.perform(get("/api/v1/auth/activate").param("token", "valid-token"))
mockMvc.perform(get("/api/v1/auth/activate-account").param("token", "valid-token"))
.andExpect(status().isOk())
.andExpect(jsonPath("$.data.enabled").value(true));
}
Expand All @@ -186,7 +186,7 @@ void _09_ShouldReturn400_WhenActivationTokenInvalid() throws Exception {
when(userService.activate("bad-token"))
.thenThrow(new InvalidTokenException("Invalid activation token"));

mockMvc.perform(get("/api/v1/auth/activate").param("token", "bad-token"))
mockMvc.perform(get("/api/v1/auth/activate-account").param("token", "bad-token"))
.andExpect(status().isBadRequest());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void _01_ShouldPassFrontendActivationLink_WhenActivationEmailIsSent() {
Context ctx = contextCaptor.getValue();
assertThat(ctx.getVariable("username")).isEqualTo("ada");
assertThat(ctx.getVariable("activationLink"))
.isEqualTo(FRONTEND_URL + "/auth/activate?token=raw-token");
.isEqualTo(FRONTEND_URL + "/auth/activate-account?token=raw-token");
verify(mailSender).send(any(MimeMessage.class));
}

Expand Down
Loading