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.*;
@RequiredArgsConstructor
public class WebController
{
- private final PasswordRestService passwordRestService;
+ private final PasswordResetService passwordResetService;
@GetMapping("/")
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);
}
@RequestParam String code,
@RequestParam String password)
{
- PasswordResetRequestProgress progress =
- passwordRestService.confirm(
+ ResetRequestProgress progress =
+ passwordResetService.confirm(
id,
code,
password);
return mav;
}
- ModelAndView createModelAndView(PasswordResetRequestProgress progress)
+ ModelAndView createModelAndView(ResetRequestProgress progress)
{
ModelAndView mav = new ModelAndView();
mav.addObject("progress", progress);
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;
+++ /dev/null
-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<UUID> userId;
- private String code;
- private String password;
- private Status status;
- private ZonedDateTime created;
- private ZonedDateTime confirmed;
- private ZonedDateTime accomplihed;
-}
+++ /dev/null
-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<ZonedDateTime> created;
- private final Optional<ZonedDateTime> confirmed;
- private final Optional<ZonedDateTime> accomplished;
-}
+++ /dev/null
-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);
-}
+++ /dev/null
-package de.juplo.demos.pwreset.api.out;
-
-import java.util.UUID;
-
-
-public interface MessagingService
-{
- void sendRestCode(UUID userId, String code);
-}
+++ /dev/null
-package de.juplo.demos.pwreset.api.out;
-
-import java.util.Optional;
-import java.util.UUID;
-
-
-public interface UsersService
-{
- Optional<UUID> getUserByEmail(String email);
- void setPassword(UUID userId, String password);
-}
--- /dev/null
+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<UUID> userId;
+ private String code;
+ private String password;
+ private Status status;
+ private ZonedDateTime created;
+ private ZonedDateTime confirmed;
+ private ZonedDateTime accomplihed;
+}
--- /dev/null
+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);
+}
--- /dev/null
+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<ZonedDateTime> created;
+ private final Optional<ZonedDateTime> confirmed;
+ private final Optional<ZonedDateTime> accomplished;
+}
--- /dev/null
+package de.juplo.demos.pwreset.domain.ports.out;
+
+import java.util.UUID;
+
+
+public interface MessagingService
+{
+ void sendRestCode(UUID userId, String code);
+}
--- /dev/null
+package de.juplo.demos.pwreset.domain.ports.out;
+
+import java.util.Optional;
+import java.util.UUID;
+
+
+public interface UsersService
+{
+ Optional<UUID> getUserByEmail(String email);
+ void setPassword(UUID userId, String password);
+}