From: Kai Moritz Date: Sun, 14 Mar 2021 12:23:26 +0000 (+0100) Subject: WIP X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=4356061f7d4ce078b66b1dc0fe346af04dbf1b8f;p=demos%2Fpact WIP --- diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/in/WebController.java b/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/in/WebController.java index b535a27..2d6b089 100644 --- a/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/in/WebController.java +++ b/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/in/WebController.java @@ -1,7 +1,7 @@ package de.juplo.demos.pwreset.adapters.in; -import de.juplo.demos.pwreset.api.domain.PasswordResetRequestProgress; -import de.juplo.demos.pwreset.api.domain.PasswordRestService; +import de.juplo.demos.pwreset.domain.ports.in.ResetRequestProgress; +import de.juplo.demos.pwreset.domain.ports.in.PasswordResetService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; @@ -16,7 +16,7 @@ import java.util.UUID; @RequiredArgsConstructor public class WebController { - private final PasswordRestService passwordRestService; + private final PasswordResetService passwordResetService; @GetMapping("/") @@ -32,14 +32,14 @@ public class WebController throws IOException { - PasswordResetRequestProgress progress = passwordRestService.request(email); + ResetRequestProgress progress = passwordResetService.request(email); httpServletResponse.sendRedirect(progress.getRequestId().toString()); } @GetMapping("/{id}") public ModelAndView getResetRequest(@PathVariable UUID id) { - PasswordResetRequestProgress progress = passwordRestService.get(id); + ResetRequestProgress progress = passwordResetService.get(id); return createModelAndView(progress); } @@ -49,8 +49,8 @@ public class WebController @RequestParam String code, @RequestParam String password) { - PasswordResetRequestProgress progress = - passwordRestService.confirm( + ResetRequestProgress progress = + passwordResetService.confirm( id, code, password); @@ -63,7 +63,7 @@ public class WebController return mav; } - ModelAndView createModelAndView(PasswordResetRequestProgress progress) + ModelAndView createModelAndView(ResetRequestProgress progress) { ModelAndView mav = new ModelAndView(); mav.addObject("progress", progress); diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/out/RemoteUsersServiceConsumer.java b/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/out/RemoteUsersServiceConsumer.java index 78c5548..7a2ac77 100644 --- a/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/out/RemoteUsersServiceConsumer.java +++ b/pwreset/src/main/java/de/juplo/demos/pwreset/adapters/out/RemoteUsersServiceConsumer.java @@ -1,6 +1,6 @@ package de.juplo.demos.pwreset.adapters.out; -import de.juplo.demos.pwreset.api.out.UsersService; +import de.juplo.demos.pwreset.domain.ports.out.UsersService; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordResetRequest.java b/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordResetRequest.java deleted file mode 100644 index d0ed22f..0000000 --- a/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordResetRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.juplo.demos.pwreset.api.domain; - -import lombok.Data; - -import java.time.ZonedDateTime; -import java.util.Optional; -import java.util.UUID; - - -@Data -public class PasswordResetRequest -{ - public enum Status - { - CREATED, - CONFIRMED, - ACCOMPLISHED - } - - private final UUID id; - private final Optional userId; - private String code; - private String password; - private Status status; - private ZonedDateTime created; - private ZonedDateTime confirmed; - private ZonedDateTime accomplihed; -} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordResetRequestProgress.java b/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordResetRequestProgress.java deleted file mode 100644 index 6cb27f3..0000000 --- a/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordResetRequestProgress.java +++ /dev/null @@ -1,23 +0,0 @@ -package de.juplo.demos.pwreset.api.domain; - -import lombok.Builder; -import lombok.Getter; -import lombok.ToString; - -import java.time.ZonedDateTime; -import java.util.Optional; -import java.util.UUID; - - -@Builder -@Getter -@ToString -public class PasswordResetRequestProgress -{ - private final UUID requestId; - private final boolean accepted; - private final String message; - private final Optional created; - private final Optional confirmed; - private final Optional accomplished; -} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordRestService.java b/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordRestService.java deleted file mode 100644 index e30ce8d..0000000 --- a/pwreset/src/main/java/de/juplo/demos/pwreset/api/domain/PasswordRestService.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.juplo.demos.pwreset.api.domain; - -import java.util.UUID; - - -public interface PasswordRestService -{ - PasswordResetRequestProgress request(String email); - PasswordResetRequestProgress get(UUID requestId); - PasswordResetRequestProgress confirm(UUID requestId, String code, String password); -} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/api/out/MessagingService.java b/pwreset/src/main/java/de/juplo/demos/pwreset/api/out/MessagingService.java deleted file mode 100644 index 460af93..0000000 --- a/pwreset/src/main/java/de/juplo/demos/pwreset/api/out/MessagingService.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.juplo.demos.pwreset.api.out; - -import java.util.UUID; - - -public interface MessagingService -{ - void sendRestCode(UUID userId, String code); -} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/api/out/UsersService.java b/pwreset/src/main/java/de/juplo/demos/pwreset/api/out/UsersService.java deleted file mode 100644 index 212b816..0000000 --- a/pwreset/src/main/java/de/juplo/demos/pwreset/api/out/UsersService.java +++ /dev/null @@ -1,11 +0,0 @@ -package de.juplo.demos.pwreset.api.out; - -import java.util.Optional; -import java.util.UUID; - - -public interface UsersService -{ - Optional getUserByEmail(String email); - void setPassword(UUID userId, String password); -} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/domain/internal/PasswordResetRequest.java b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/internal/PasswordResetRequest.java new file mode 100644 index 0000000..9a79b25 --- /dev/null +++ b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/internal/PasswordResetRequest.java @@ -0,0 +1,28 @@ +package de.juplo.demos.pwreset.domain.internal; + +import lombok.Data; + +import java.time.ZonedDateTime; +import java.util.Optional; +import java.util.UUID; + + +@Data +public class PasswordResetRequest +{ + public enum Status + { + CREATED, + CONFIRMED, + ACCOMPLISHED + } + + private final UUID id; + private final Optional userId; + private String code; + private String password; + private Status status; + private ZonedDateTime created; + private ZonedDateTime confirmed; + private ZonedDateTime accomplihed; +} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/in/PasswordResetService.java b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/in/PasswordResetService.java new file mode 100644 index 0000000..833edd8 --- /dev/null +++ b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/in/PasswordResetService.java @@ -0,0 +1,11 @@ +package de.juplo.demos.pwreset.domain.ports.in; + +import java.util.UUID; + + +public interface PasswordResetService +{ + ResetRequestProgress request(String email); + ResetRequestProgress get(UUID requestId); + ResetRequestProgress confirm(UUID requestId, String code, String password); +} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/in/ResetRequestProgress.java b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/in/ResetRequestProgress.java new file mode 100644 index 0000000..5e70f5e --- /dev/null +++ b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/in/ResetRequestProgress.java @@ -0,0 +1,23 @@ +package de.juplo.demos.pwreset.domain.ports.in; + +import lombok.Builder; +import lombok.Getter; +import lombok.ToString; + +import java.time.ZonedDateTime; +import java.util.Optional; +import java.util.UUID; + + +@Builder +@Getter +@ToString +public class ResetRequestProgress +{ + private final UUID requestId; + private final boolean accepted; + private final String message; + private final Optional created; + private final Optional confirmed; + private final Optional accomplished; +} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/out/MessagingService.java b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/out/MessagingService.java new file mode 100644 index 0000000..b05411f --- /dev/null +++ b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/out/MessagingService.java @@ -0,0 +1,9 @@ +package de.juplo.demos.pwreset.domain.ports.out; + +import java.util.UUID; + + +public interface MessagingService +{ + void sendRestCode(UUID userId, String code); +} diff --git a/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/out/UsersService.java b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/out/UsersService.java new file mode 100644 index 0000000..b314c86 --- /dev/null +++ b/pwreset/src/main/java/de/juplo/demos/pwreset/domain/ports/out/UsersService.java @@ -0,0 +1,11 @@ +package de.juplo.demos.pwreset.domain.ports.out; + +import java.util.Optional; +import java.util.UUID; + + +public interface UsersService +{ + Optional getUserByEmail(String email); + void setPassword(UUID userId, String password); +}