Ver Fonte

final commit, private information hidden, code cleaned from commented code and logs

mateuszsudra há 2 anos atrás
pai
commit
ab44b15290
35 ficheiros alterados com 23 adições e 385 exclusões
  1. 0 50
      boat-reservation-logic/pom.xml
  2. 1 1
      boat-reservation-logic/src/main/java/pl/sudra/configuration/CorsConfig.java
  3. 2 2
      boat-reservation-logic/src/main/java/pl/sudra/configuration/EmailManagerConfiguration.java
  4. 0 2
      boat-reservation-logic/src/main/java/pl/sudra/configuration/SecurityConfig.java
  5. 0 9
      boat-reservation-logic/src/main/java/pl/sudra/configuration/SpringConfiguration.java
  6. 0 1
      boat-reservation-logic/src/main/java/pl/sudra/configuration/SpringInit.java
  7. 3 4
      boat-reservation-logic/src/main/java/pl/sudra/controller/BillController.java
  8. 5 3
      boat-reservation-logic/src/main/java/pl/sudra/controller/BoatController.java
  9. 0 1
      boat-reservation-logic/src/main/java/pl/sudra/controller/PdfController.java
  10. 3 23
      boat-reservation-logic/src/main/java/pl/sudra/controller/ReservationController.java
  11. 4 0
      boat-reservation-logic/src/main/java/pl/sudra/controller/UserController.java
  12. 0 34
      boat-reservation-logic/src/main/java/pl/sudra/domain/Reservation.java
  13. 1 26
      boat-reservation-logic/src/main/java/pl/sudra/domain/User.java
  14. 1 1
      boat-reservation-logic/src/main/java/pl/sudra/repository/BillRepository.java
  15. 0 4
      boat-reservation-logic/src/main/java/pl/sudra/repository/ReservationRepository.java
  16. 1 0
      boat-reservation-logic/src/main/java/pl/sudra/repository/RoleRepository.java
  17. 0 36
      boat-reservation-logic/src/main/java/pl/sudra/securityController/CustomExceptionHandler.java
  18. 0 10
      boat-reservation-logic/src/main/java/pl/sudra/securityController/CustomInterceptor.java
  19. 0 79
      boat-reservation-logic/src/main/java/pl/sudra/securityController/JwtRequestFilter.java
  20. 1 3
      boat-reservation-logic/src/main/java/pl/sudra/securityController/JwtTokenUtil.java
  21. 0 3
      boat-reservation-logic/src/main/java/pl/sudra/securityController/SecurityController.java
  22. 0 3
      boat-reservation-logic/src/main/java/pl/sudra/service/EmailServiceImpl.java
  23. 0 16
      boat-reservation-logic/src/main/java/pl/sudra/service/PdfServiceImpl.java
  24. 1 1
      boat-reservation-logic/src/main/java/pl/sudra/service/ReCaptchaServiceImpl.java
  25. 0 2
      boat-reservation-logic/src/main/java/pl/sudra/service/ReservationService.java
  26. 0 35
      boat-reservation-logic/src/main/java/pl/sudra/service/ReservationServiceImpl.java
  27. 0 3
      boat-reservation-view/src/app/admin-panel/admin-panel.component.ts
  28. 0 6
      boat-reservation-view/src/app/app.component.ts
  29. 0 2
      boat-reservation-view/src/app/footer/footer.component.ts
  30. 0 3
      boat-reservation-view/src/app/login-view/login-view.component.ts
  31. 0 9
      boat-reservation-view/src/app/manager-panel/manager-panel.component.ts
  32. 0 4
      boat-reservation-view/src/app/profile-page/profile-page.component.ts
  33. 0 5
      boat-reservation-view/src/app/register-view/register-view.component.ts
  34. 0 2
      boat-reservation-view/src/app/reservation-view/reservation-view.component.ts
  35. 0 2
      boat-reservation-view/src/app/services/auth.service.ts

+ 0 - 50
boat-reservation-logic/pom.xml

@@ -109,52 +109,18 @@
             <artifactId>jakarta.json</artifactId>
             <version>2.0.1</version>
         </dependency>
-<!--&lt;!&ndash;        test&ndash;&gt;-->
-<!--        <dependency>-->
-<!--            <groupId>org.springframework.boot</groupId>-->
-<!--            <artifactId>spring-boot-starter-mail</artifactId>-->
-<!--            <version>2.2.6.RELEASE</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>com.sun.mail</groupId>-->
-<!--            <artifactId>jakarta.mail</artifactId>-->
-<!--            <version>1.6.5</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.springframework</groupId>-->
-<!--            <artifactId>spring-context-support</artifactId>-->
-<!--            <version>5.2.5.RELEASE</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>org.springframework.boot</groupId>-->
-<!--            <artifactId>spring-boot-starter-mail</artifactId>-->
-<!--            <version>2.2.6.RELEASE</version>-->
-<!--        </dependency>-->
-
         <!-- for pdf generation -->
         <dependency>
             <groupId>com.itextpdf</groupId>
             <artifactId>itextpdf</artifactId>
             <version>5.5.13.3</version>
         </dependency>
-
-
         <!-- for sending emails -->
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context-support</artifactId>
             <version>6.0.7</version>
         </dependency>
-<!--        <dependency>-->
-<!--            <groupId>jakarta.mail</groupId>-->
-<!--            <artifactId>jakarta.mail-api</artifactId>-->
-<!--            <version>2.1.1</version>-->
-<!--        </dependency>-->
-<!--        <dependency>-->
-<!--            <groupId>com.sun.mail</groupId>-->
-<!--            <artifactId>jakarta.mail</artifactId>-->
-<!--            <version>2.0.1</version>-->
-<!--        </dependency>-->
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-mail</artifactId>
@@ -178,12 +144,6 @@
             <artifactId>spring-security-jwt</artifactId>
             <version>1.1.1.RELEASE</version>
         </dependency>
-        <!-- https://mvnrepository.com/artifact/org.springframework/spring-context-support -->
-        <!--        <dependency>-->
-        <!--            <groupId>org.springframework</groupId>-->
-        <!--            <artifactId>spring-context-support</artifactId>-->
-        <!--            <version>6.0.9</version>-->
-        <!--        </dependency>-->
         <dependency>
             <groupId>io.jsonwebtoken</groupId>
             <artifactId>jjwt-api</artifactId>
@@ -201,16 +161,6 @@
             <version>0.11.2</version>
             <scope>runtime</scope>
         </dependency>
-        <!--        &lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.security/spring-security-web &ndash;&gt;-->
-        <!--        <dependency>-->
-        <!--            <groupId>org.springframework.security</groupId>-->
-        <!--            <artifactId>spring-security-web</artifactId>-->
-        <!--            <version>6.1.0</version>-->
-        <!--        </dependency>-->
-        <!--        <dependency>-->
-        <!--            <groupId>org.springframework.boot</groupId>-->
-        <!--            <artifactId>spring-boot-starter-security</artifactId>-->
-        <!--        </dependency>-->
 
     </dependencies>
 

+ 1 - 1
boat-reservation-logic/src/main/java/pl/sudra/configuration/CorsConfig.java

@@ -11,7 +11,7 @@ public class CorsConfig implements WebMvcConfigurer {
     @Override
     public void addCorsMappings(CorsRegistry registry) {
         registry.addMapping("/**")
-                .allowedOrigins("http://localhost:1410") // Adjust with your Angular frontend URL
+                .allowedOrigins("http://localhost:1410")
                 .allowedMethods("GET", "POST", "PUT", "DELETE")
                 .allowedHeaders("*");
     }

+ 2 - 2
boat-reservation-logic/src/main/java/pl/sudra/configuration/EmailManagerConfiguration.java

@@ -16,8 +16,8 @@ public class EmailManagerConfiguration {
         mailSender.setHost("smtp.gmail.com");
         mailSender.setPort(587); //SSL config
 
-        mailSender.setUsername("mateusz.sudra.21@gmail.com");
-        mailSender.setPassword("jupjlcrapzgpxwah");
+        mailSender.setUsername("EMAIL");
+        mailSender.setPassword("PASSWORD");
 
         Properties props = mailSender.getJavaMailProperties();
         props.put("mail.transport.protocol", "smtp");

+ 0 - 2
boat-reservation-logic/src/main/java/pl/sudra/configuration/SecurityConfig.java

@@ -9,7 +9,6 @@ import org.springframework.security.web.SecurityFilterChain;
 @Configuration
 @EnableWebSecurity
 public class SecurityConfig {
-
     @Bean
     public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
         http.authorizeHttpRequests().anyRequest().authenticated();
@@ -17,5 +16,4 @@ public class SecurityConfig {
 
         return http.build();
     }
-
 }

+ 0 - 9
boat-reservation-logic/src/main/java/pl/sudra/configuration/SpringConfiguration.java

@@ -37,7 +37,6 @@ import java.util.Locale;
 @EnableScheduling
 @EnableTransactionManagement
 @ComponentScan("pl.sudra")
-//@Import({SecurityConfiguration.class})
 public class SpringConfiguration implements WebMvcConfigurer {
     @Bean
     public InternalResourceViewResolver viewResolver() {
@@ -91,9 +90,6 @@ public class SpringConfiguration implements WebMvcConfigurer {
         return new BCryptPasswordEncoder();
     }
 
-//    @Resource(name = "addressService")
-//    private AddressService addressService;
-//
     @Resource(name = "roleService")
     private RoleService roleService;
 
@@ -103,11 +99,6 @@ public class SpringConfiguration implements WebMvcConfigurer {
         formatterRegistry.addConverter(getRoleListConverter());
     }
 
-//    @Bean
-//    public AddressConverter getMyAddressConverter() {
-//        return new AddressConverter(addressService);
-//    }
-//
     @Bean
     public RoleConverter getRoleConverter() {
         return new RoleConverter(roleService);

+ 0 - 1
boat-reservation-logic/src/main/java/pl/sudra/configuration/SpringInit.java

@@ -14,7 +14,6 @@ public class SpringInit extends AbstractAnnotationConfigDispatcherServletInitial
                 SpringConfiguration.class,
                 HibernatePersistenceConfiguration.class,
                 CorsConfig.class
-//                EmailManagerConfiguration.class
         };
     }
 

+ 3 - 4
boat-reservation-logic/src/main/java/pl/sudra/controller/BillController.java

@@ -7,11 +7,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 import pl.sudra.domain.Bill;
-import pl.sudra.domain.Boat;
 import pl.sudra.service.BillService;
 
-import java.util.List;
-
 @RestController
 @CrossOrigin(origins = "http://localhost:1410")
 public class BillController {
@@ -27,7 +24,7 @@ public class BillController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public Bill getBill(@Param("id") Long id) {
-        System.out.println("Getting Bill");
+        System.out.println("Getting Bill by id");
         return billService.getBill(id);
     }
 
@@ -36,6 +33,7 @@ public class BillController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public void confirmBill(@Param("id") Long id) {
+        System.out.println("Confirming Bill by id");
         billService.confirmReservation(id);
     }
 
@@ -44,6 +42,7 @@ public class BillController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public void cancelBill(@Param("id") Long id) {
+        System.out.println("Cancel Bill by id");
         billService.cancelReservation(id);
     }
 }

+ 5 - 3
boat-reservation-logic/src/main/java/pl/sudra/controller/BoatController.java

@@ -33,7 +33,7 @@ public class BoatController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public List<Boat> listAddressesXML() {
-        System.out.println("Getting Boats");
+        System.out.println("Getting Boats JSON");
         return boatService.getBoats();
     }
 
@@ -42,11 +42,11 @@ public class BoatController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_XML_VALUE)
     public List<Boat> listAddressesJSON() {
-        System.out.println("Getting Boats");
+        System.out.println("Getting Boats XML");
         return boatService.getBoats();
     }
 
-    //    test request
+    // test request
     @RequestMapping(value = "/hello", method = RequestMethod.GET)
     public String sayHello() {
         System.out.println("Greetings!");
@@ -55,6 +55,7 @@ public class BoatController {
 
     @RequestMapping(value = "/addBoat", method = RequestMethod.POST)
     public boolean addBoat(@RequestBody Boat boat) {
+        System.out.println("Creating boat");
         System.out.println(boat.toString());
         boatService.addBoat(boat);
         return true;
@@ -66,6 +67,7 @@ public class BoatController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public String getBoatNameById(@RequestParam("id") Long id) {
+        System.out.println("Getting Boat by id");
         return this.boatService.getBoat(id).getName();
     }
 }

+ 0 - 1
boat-reservation-logic/src/main/java/pl/sudra/controller/PdfController.java

@@ -34,6 +34,5 @@ public class PdfController {
         emailService.sendMailWithPDF(username,
                 "Hello " + username + "!\n\nIn the attachment you can find billing with all your reservations.\n\nHave a good day!",
                 "Oslo Boating Service. Your billing is here!");
-//        pdfService.generatePDF(userService.findByUsername(username).get());
     }
 }

+ 3 - 23
boat-reservation-logic/src/main/java/pl/sudra/controller/ReservationController.java

@@ -2,15 +2,12 @@ package pl.sudra.controller;
 
 import org.springframework.http.MediaType;
 import org.springframework.web.bind.annotation.*;
-//import pl.sudra.domain.Bill;
-//import pl.sudra.domain.Reservation;
 import pl.sudra.domain.Bill;
 import pl.sudra.domain.Reservation;
 import pl.sudra.repository.UserRepository;
 import pl.sudra.service.BillService;
 import pl.sudra.service.BoatService;
 import pl.sudra.service.ReservationService;
-import pl.sudra.service.UserService;
 
 import java.sql.Date;
 import java.util.List;
@@ -31,30 +28,12 @@ public class ReservationController {
         this.userRepository = userRepository;
     }
 
-    @RequestMapping(
-            value = "/generateReservations",
-            method = RequestMethod.GET,
-            produces = MediaType.APPLICATION_JSON_VALUE)
-    public void generateReservations(@RequestParam("n") int n) {
-        System.out.println("Generation of reservations");
-        this.reservationService.generateReservations(n);
-    }
-
     @RequestMapping(
             value = "/createReservation",
             method = RequestMethod.POST,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public void createReservation(@RequestBody Reservation reservation) {
         System.out.println("Creating reservation");
-//        Bill bill = new Bill();
-
-//        bill.setReservation(reservation);
-//        System.out.println(reservation.getBoatId());
-//        bill.setTotalCost(
-//                this.boatService.getBoat(reservation.getBoatId()).getCost()
-//                        * (reservation.getEndHour() - reservation.getStartHour()));
-//        bill.setIssueDate(new java.sql.Date());
-//        bill.setStatus(false);
         Bill bill = new Bill(
                 reservation,
                 "Pending",
@@ -76,7 +55,7 @@ public class ReservationController {
             produces = MediaType.APPLICATION_JSON_VALUE)
     public List<Reservation> findReservations(@RequestParam("boat_id") Long boat_id,
                                               @RequestParam("date") Date date) {
-        System.out.println("Looking for reservations");
+        System.out.println("Looking for reservations by boat id and date");
         return this.reservationService.findReservations(boat_id, date);
     }
 
@@ -85,7 +64,7 @@ public class ReservationController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public List<Reservation> findReservationsOfUsername(@RequestParam("user_id") Long user_id) {
-        System.out.println("Looking for reservations");
+        System.out.println("Looking for reservations by user id");
         return this.reservationService.findReservationsByUserId(user_id);
     }
 
@@ -94,6 +73,7 @@ public class ReservationController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public List<Reservation> findAllReservations() {
+        System.out.println("Getting all reservations");
         return this.reservationService.getReservations();
     }
 }

+ 4 - 0
boat-reservation-logic/src/main/java/pl/sudra/controller/UserController.java

@@ -33,6 +33,7 @@ public class UserController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public List<User> getAllUsers() {
+        System.out.println("Getting all the users");
         return this.userService.getAll();
     }
 
@@ -41,6 +42,7 @@ public class UserController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public User getUser(@Param("username") String username) {
+        System.out.println("Getting user by id");
         return this.userService.findByUsername(username).get();
     }
 
@@ -49,6 +51,7 @@ public class UserController {
             method = RequestMethod.GET,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public void updateUser(@Param("id") Long id, @Param("roles") String[] roles) {
+        System.out.println("Updating user roles");
         System.out.println(Arrays.toString(roles));
         this.userService.updateUserRole(id, roles);
     }
@@ -57,6 +60,7 @@ public class UserController {
             method = RequestMethod.DELETE,
             produces = MediaType.APPLICATION_JSON_VALUE)
     public void deleteUser(@Param("id") Long id) {
+        System.out.println("Deleting user");
         this.userService.deleteUser(id);
     }
 

+ 0 - 34
boat-reservation-logic/src/main/java/pl/sudra/domain/Reservation.java

@@ -1,7 +1,5 @@
 package pl.sudra.domain;
 
-import com.fasterxml.jackson.annotation.JsonBackReference;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import jakarta.persistence.*;
 import jakarta.validation.constraints.NotNull;
@@ -15,11 +13,6 @@ public class Reservation {
     @Id
     @GeneratedValue(strategy = GenerationType.AUTO)
     private Long id;
-    //    @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
-//    @JoinColumn(name = "user_id")
-//    @JsonBackReference
-//    @NotNull
-//    private Long userId;
 
     @ManyToOne(fetch = FetchType.EAGER)
     @JoinColumn(name = "userId")
@@ -36,8 +29,6 @@ public class Reservation {
 
     @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
     @JoinColumn(name = "billId")
-//    @JsonIgnore
-//    @MapsId
     private Bill bill;
 
     @Override
@@ -53,14 +44,6 @@ public class Reservation {
                 '}';
     }
 
-    //    public Reservation(Long userId, Long boatId, Date date, byte startHour, byte endHour) {
-//        this.userId = userId;
-//        this.boatId = boatId;
-//        this.date = date;
-//        this.startHour = startHour;
-//        this.endHour = endHour;
-//    }
-
     public Reservation() {
     }
 
@@ -72,15 +55,6 @@ public class Reservation {
         this.id = id;
     }
 
-//    public Long getUserId() {
-//        return userId;
-//    }
-
-//    public void setUserId(Long user_id) {
-//        this.userId = user_id;
-//    }
-
-
     public User getUser() {
         return user;
     }
@@ -120,14 +94,6 @@ public class Reservation {
     public void setEndHour(byte end_hour) {
         this.endHour = end_hour;
     }
-//
-//    public Long getUserId() {
-//        return user;
-//    }
-//
-//    public void setUser(User user) {
-//        this.user = user;
-//    }
 
     public Bill getBill() {
         return bill;

+ 1 - 26
boat-reservation-logic/src/main/java/pl/sudra/domain/User.java

@@ -6,11 +6,9 @@ import jakarta.validation.constraints.NotBlank;
 import jakarta.validation.constraints.NotNull;
 import jakarta.validation.constraints.Size;
 
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-import java.util.stream.Collectors;
 
 @Entity
 @Table(name = "user")
@@ -39,10 +37,6 @@ public class User {
     @NotNull
     private boolean enabled = false;
 
-//    public void setRole(String role) {
-//        this.role = role;
-//    }
-
     public boolean isEnabled() {
         return enabled;
     }
@@ -75,7 +69,7 @@ public class User {
     }
 
     public String[] getRolesForToken() {
-        Set<Role> appUserRoles = getRole(); // Assuming you have a method to retrieve the Set<AppUserRole>
+        Set<Role> appUserRoles = getRole();
 
         String[] rolesArray = appUserRoles.stream()
                 .map(Role::getRole)
@@ -90,13 +84,6 @@ public class User {
     public void setRole(Set<Role> role) {
         this.role = role;
     }
-//    public User(Long id, String username, String password, String email, String role) {
-//        this.id = id;
-//        this.username = username;
-//        this.password = password;
-//        this.email = email;
-//        this.role = role;
-//    }
 
     public Long getId() {
         return id;
@@ -126,10 +113,6 @@ public class User {
         return role;
     }
 
-//    public void setRole(String role) {
-//        this.role = role;
-//    }
-
     public String getPassword() {
         return password;
     }
@@ -137,12 +120,4 @@ public class User {
     public void setPassword(String password) {
         this.password = password;
     }
-
-//    public List<Reservation> getReservations() {
-//        return reservations;
-//    }
-
-//    public void setReservations(List<Reservation> reservations) {
-//        this.reservations = reservations;
-//    }
 }

+ 1 - 1
boat-reservation-logic/src/main/java/pl/sudra/repository/BillRepository.java

@@ -5,7 +5,7 @@ import pl.sudra.domain.Bill;
 
 import java.util.List;
 
-public interface BillRepository  extends JpaRepository<Bill, Long> {
+public interface BillRepository extends JpaRepository<Bill, Long> {
     Bill findBillById(long id);
 
     List<Bill> findAllByStatus(String waitingForPayment);

+ 0 - 4
boat-reservation-logic/src/main/java/pl/sudra/repository/ReservationRepository.java

@@ -14,10 +14,6 @@ import java.util.List;
 public interface ReservationRepository extends JpaRepository<Reservation, Long> {
     Reservation findReservationById(long id);
 
-//    List<Reservation> findAllByBoatIdAndDate(long id, Date date);
-//    @EntityGraph(attributePaths = "bill")
-//    @Query("SELECT r FROM Reservation r WHERE r.boatId = :boatId AND r.date = :date")
-//    @Query("SELECT new com.example.dto.ReservationDTO(r.id, r.date, r.startHour, r.endHour) FROM Reservation r WHERE r.boatId = :boatId AND r.date = :date")
     List<Reservation> findAllByBoatIdAndDate(@Param("boatId") Long boatId, @Param("date") Date date);
 
     List<Reservation> findReservationsByUserId(Long userId);

+ 1 - 0
boat-reservation-logic/src/main/java/pl/sudra/repository/RoleRepository.java

@@ -7,5 +7,6 @@ import java.util.Optional;
 
 public interface RoleRepository extends JpaRepository<Role, Long> {
     Optional<Role> findByRole(String role);
+
     Optional<Role> findById(Long id);
 }

+ 0 - 36
boat-reservation-logic/src/main/java/pl/sudra/securityController/CustomExceptionHandler.java

@@ -1,36 +0,0 @@
-//package pl.sudra.securityController;
-//
-//import org.springframework.http.HttpHeaders;
-//import org.springframework.http.HttpStatus;
-//import org.springframework.http.ResponseEntity;
-//import org.springframework.web.bind.MethodArgumentNotValidException;
-//import org.springframework.web.bind.annotation.RestControllerAdvice;
-//import org.springframework.web.context.request.WebRequest;
-//import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
-//import org.springframework.context.support.DefaultMessageSourceResolvable;
-//
-//
-//import java.util.List;
-//import java.util.stream.Collectors;
-//
-//
-//@RestControllerAdvice
-//public class CustomExceptionHandler extends ResponseEntityExceptionHandler {
-//
-//    protected ResponseEntity<Object> handleMethodArgumentNotValid(MethodArgumentNotValidException ex,
-//                                                                  HttpHeaders headers,
-//                                                                  HttpStatus status,
-//                                                                  WebRequest request) {
-//        List<String> errors = ex.getBindingResult()
-//                .getAllErrors()
-//                .stream()
-//                .map(DefaultMessageSourceResolvable::getDefaultMessage)
-//                .collect(Collectors.toList());
-//
-//        ValidationErrorResponse errorResponse = new ValidationErrorResponse();
-//        errorResponse.setMessage("Validation Error");
-//        errorResponse.setErrors(errors);
-//
-//        return ResponseEntity.badRequest().body(errorResponse);
-//    }
-//}

+ 0 - 10
boat-reservation-logic/src/main/java/pl/sudra/securityController/CustomInterceptor.java

@@ -58,18 +58,8 @@ public class CustomInterceptor implements HandlerInterceptor {
             response.setHeader("Access-Control-Max-Age", "3600");
             return true;
         }
-//        System.out.println("test: " + request.getHeader("access-control-request-headers"));
-//        System.out.println("test here: " + request.getHeader("access-control-request-headers.authorization"));
 
         String endpoint = request.getRequestURI();
-//        System.out.println(request.getHeaderNames().toString());
-//        Enumeration<String> headerNames = request.getHeaderNames();
-//        while (headerNames.hasMoreElements()) {
-//            String headerName = headerNames.nextElement();
-//            String headerValue = request.getHeader(headerName);
-//            System.out.println(headerName + ": " + headerValue);
-//        }
-        // if endpoint require no authorization
         if (noAuth.contains(endpoint)) {
             return HandlerInterceptor.super.preHandle(request, response, handler);
         }

+ 0 - 79
boat-reservation-logic/src/main/java/pl/sudra/securityController/JwtRequestFilter.java

@@ -1,79 +0,0 @@
-//package pl.sudra.securityController;
-//
-//import io.jsonwebtoken.ExpiredJwtException;
-//import jakarta.servlet.FilterChain;
-//import jakarta.servlet.ServletException;
-//import jakarta.servlet.http.HttpServletRequest;
-//import jakarta.servlet.http.HttpServletResponse;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-//import org.springframework.security.core.context.SecurityContextHolder;
-//import org.springframework.security.core.userdetails.UserDetails;
-//import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
-//import org.springframework.web.bind.annotation.CrossOrigin;
-//import org.springframework.web.bind.annotation.RestController;
-//import org.springframework.web.filter.OncePerRequestFilter;
-//import pl.sudra.domain.User;
-//import pl.sudra.service.UserService;
-//
-//import java.io.IOException;
-//import java.util.ArrayList;
-//import java.util.List;
-//
-//@RestController
-//@CrossOrigin(origins = "http://localhost:1410")
-//public class JwtRequestFilter extends OncePerRequestFilter {
-//    @Autowired
-//    private UserService userService;
-//
-//    @Autowired
-//    private JwtTokenUtil jwtTokenUtil;
-//
-//    @Override
-//    protected void doFilterInternal(HttpServletRequest request,
-//                                    HttpServletResponse response,
-//                                    FilterChain chain) throws ServletException, IOException {
-//        final String requestTokenHeader = request.getHeader("Authorization");
-//        System.out.println("Im doing something");
-//        String username = null;
-//        String jwtToken = null;// JWT Token is in the form "Bearer token". Remove Bearer word and get only the Token
-//
-//        if (requestTokenHeader != null && requestTokenHeader.startsWith("Bearer ")) {
-//            jwtToken = requestTokenHeader.substring(7);
-//            try {
-//                username = jwtTokenUtil.getUsernameFromToken(jwtToken);
-//            } catch (IllegalArgumentException e) {
-//                System.out.println("Unable to get JWT Token");
-//            } catch (ExpiredJwtException e) {
-//                System.out.println("JWT Token has expired");
-//            }
-//        } else {
-//            logger.warn("JWT Token does not begin with Bearer String");
-//        }
-//
-//        //Once we get the token validate it.
-//        if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
-//
-//            User user = this.userService.findByUsername(username).get();
-//
-//            // if token is valid configure Spring Security to manually set authentication
-//            if (jwtTokenUtil.validateToken(jwtToken, user)) {
-//
-////                UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
-////                        new UsernamePasswordAuthenticationToken(user,
-////                                null, user.getRole());
-//
-//                UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken =
-//                        new UsernamePasswordAuthenticationToken(user,
-//                                null, List.of());
-//                usernamePasswordAuthenticationToken
-//                        .setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
-//                // After setting the Authentication in the context, we specify
-//                // that the current user is authenticated. So it passes the Spring Security Configurations successfully.
-//                SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
-//            }
-//        }
-//        chain.doFilter(request, response);
-//    }
-//
-//}

+ 1 - 3
boat-reservation-logic/src/main/java/pl/sudra/securityController/JwtTokenUtil.java

@@ -1,12 +1,10 @@
 package pl.sudra.securityController;
 
-import com.sun.jdi.event.ExceptionEvent;
 import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.ExpiredJwtException;
 import io.jsonwebtoken.Jwts;
 import io.jsonwebtoken.SignatureAlgorithm;
 import org.springframework.stereotype.Component;
-import pl.sudra.domain.User;
 
 import java.util.Date;
 import java.util.function.Function;
@@ -14,7 +12,7 @@ import java.util.function.Function;
 @Component
 public class JwtTokenUtil {
 
-    private static final String SECRET_KEY = "SuperSecureKey2023".repeat(5); // Replace with your own secret key
+    private static final String SECRET_KEY = "SuperSecureKey2023".repeat(5);
 
     private static final long EXPIRATION_TIME = 1000 * 60 * 60 * 1; // 1 hour
     private static final long EXPIRATION_TIME_USER_ACTIVATION = 1000 * 60 * 60 * 24; // 1 day

+ 0 - 3
boat-reservation-logic/src/main/java/pl/sudra/securityController/SecurityController.java

@@ -89,9 +89,6 @@ public class SecurityController {
         System.out.println("register - setting client role");
         Set<Role> roles = new HashSet<>();
         roles.add(roleService.getRole(0L));
-//        System.out.println("CLIENT ROLE" + client_role.toString());
-//        String roles = client_role.getRole();
-//        roles.add(client_role);
 
         user.setRole(roles);
 

+ 0 - 3
boat-reservation-logic/src/main/java/pl/sudra/service/EmailServiceImpl.java

@@ -18,7 +18,6 @@ import pl.sudra.domain.Reservation;
 import pl.sudra.domain.User;
 
 import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Objects;
@@ -67,7 +66,6 @@ public class EmailServiceImpl implements EmailService {
         document.add(new Paragraph("\tUser Info:\n\n"));
 
         PdfPTable userInfoTable = new PdfPTable(4);
-//        userInfoTable.setWidthPercentage(100);
         userInfoTable.setWidths(new float[]{30.0F, 90.0F, 170.0F, 60.0F});
         System.out.println("WIDTH: " + userInfoTable.getTotalWidth());
 
@@ -130,7 +128,6 @@ public class EmailServiceImpl implements EmailService {
 
     @Override
     public void sendMailWithPDF(String username, String content, String subject) throws MailException, MessagingException, DocumentException {
-//        SimpleMailMessage mail = new SimpleMailMessage();
         MimeMessage message = javaMailSender.createMimeMessage();
         MimeMessageHelper helper = new MimeMessageHelper(message, true);
 

+ 0 - 16
boat-reservation-logic/src/main/java/pl/sudra/service/PdfServiceImpl.java

@@ -31,22 +31,16 @@ public class PdfServiceImpl implements PdfService{
             PdfPTable table = new PdfPTable(2);
             table.addCell("FirsName");
             table.addCell("appUser.getFirstName()");
-//            table.addCell(appUser.getFirstName());
             table.addCell("LastName");
             table.addCell("appUser.getLastName()");
-//            table.addCell(appUser.getLastName());
             table.addCell("PESEL");
             table.addCell("appUser.getPesel().getPESEL()");
-//            table.addCell(appUser.getPesel().getPESEL());
             table.addCell("Login");
             table.addCell("appUser.getLogin()");
-//            table.addCell(appUser.getLogin());
             table.addCell("Email");
             table.addCell("appUser.getEmail()");
-//            table.addCell(appUser.getEmail());
             table.addCell("Active");
             table.addCell("String.valueOf(appUser.isEnabled())");
-//            table.addCell(String.valueOf(appUser.isEnabled()));
             pdf.add(table);
             pdf.close();
             o.close();
@@ -61,10 +55,6 @@ public class PdfServiceImpl implements PdfService{
     public ByteArrayOutputStream generatePDF(User user) {
         try{
             ByteArrayOutputStream o = new ByteArrayOutputStream();
-//            ByteArrayOutputStream o = response.getOutputStream();
-//            response.setCharacterEncoding("UTF-8");
-//            response.setContentType("application/pdf");
-//            response.setHeader("Content-Disposition", "inline; filename=" + user.getUsername() + ".pdf");
             Document pdf = new Document();
             PdfWriter.getInstance(pdf, o);
             pdf.open();
@@ -73,22 +63,16 @@ public class PdfServiceImpl implements PdfService{
             PdfPTable table = new PdfPTable(2);
             table.addCell("FirsName");
             table.addCell("appUser.getFirstName()");
-//            table.addCell(appUser.getFirstName());
             table.addCell("LastName");
             table.addCell("appUser.getLastName()");
-//            table.addCell(appUser.getLastName());
             table.addCell("PESEL");
             table.addCell("appUser.getPesel().getPESEL()");
-//            table.addCell(appUser.getPesel().getPESEL());
             table.addCell("Login");
             table.addCell("appUser.getLogin()");
-//            table.addCell(appUser.getLogin());
             table.addCell("Email");
             table.addCell("appUser.getEmail()");
-//            table.addCell(appUser.getEmail());
             table.addCell("Active");
             table.addCell("String.valueOf(appUser.isEnabled())");
-//            table.addCell(String.valueOf(appUser.isEnabled()));
             pdf.add(table);
             pdf.close();
             o.close();

+ 1 - 1
boat-reservation-logic/src/main/java/pl/sudra/service/ReCaptchaServiceImpl.java

@@ -15,7 +15,7 @@ import java.net.URL;
 @Service
 public class ReCaptchaServiceImpl implements ReCaptchaService {
     private static final String URL = "https://www.google.com/recaptcha/api/siteverify";
-    private static final String GOOGLE_KEY = "6LcqrYQlAAAAAAdyX-4dWY-jGPPomTtWRd6pIpk6";
+    private static final String GOOGLE_KEY = "GOOGLE_CAPTCHA_KEY";
 
     @Override
     public boolean verify(String captcha) {

+ 0 - 2
boat-reservation-logic/src/main/java/pl/sudra/service/ReservationService.java

@@ -17,8 +17,6 @@ public interface ReservationService {
 
     Reservation getReservation(long id);
 
-    void generateReservations(int n);
-
     List<Reservation> findReservations(long boat_id, Date date);
 
     Reservation findById(long id);

+ 0 - 35
boat-reservation-logic/src/main/java/pl/sudra/service/ReservationServiceImpl.java

@@ -51,40 +51,6 @@ public class ReservationServiceImpl implements ReservationService {
         return this.reservationRepository.findReservationById(id);
     }
 
-    @Override
-    public void generateReservations(int n) {
-
-    }
-
-//    @Override
-//    public void generateReservations(int n) {
-////        Date today = new Date();
-//        LocalDate today = LocalDate.now();
-//        System.out.println("n: " + n);
-//
-//        Random random = new Random();
-//
-//        Calendar calendar = Calendar.getInstance();
-//
-//        for (int i = 0; i < n; i++) {
-//            byte start_hour = (byte) (random.nextInt(23 - 7) + 7);
-//            byte end_hour = (byte) (random.nextInt(24 - start_hour + 1) + start_hour + 1);
-//
-////            calendar.setTime(today);
-////            calendar.add(Calendar.DAY_OF_YEAR, -1 + i);
-////            System.out.println(calendar.getTime());
-//
-////            this.reservationRepository.save(
-////                    new Reservation(
-////                            (long) i,
-////                            (long) (i % 2),
-////                            (java.sql.Date) Date.valueOf(today.plusDays(-1 + i)),
-////                            start_hour, end_hour
-////                    ).setDate;
-////            );
-//        }
-//    }
-
     @Override
     @Transactional
     public List<Reservation> findReservations(long boat_id, Date date) {
@@ -102,7 +68,6 @@ public class ReservationServiceImpl implements ReservationService {
     }
 
     // every hour at 0 minutes
-//    @Scheduled(cron = "0 0 * * * *")
     @Scheduled(cron = "0 0 * * * *")
     public void updateBill() {
         java.util.Date currentDate = new java.util.Date();

+ 0 - 3
boat-reservation-view/src/app/admin-panel/admin-panel.component.ts

@@ -14,7 +14,6 @@ export class AdminPanelComponent {
   constructor(private userService: UserService) {
     this.userService.getAllUsers().subscribe(
       (users) => {
-        console.log(users)
         users.forEach(user => {
           this.users.push(
             new User(
@@ -26,7 +25,6 @@ export class AdminPanelComponent {
               user.enabled))
         })
         this.users.sort((a, b) => a.id - b.id)
-        console.log(this.users)
       }
     )
   }
@@ -49,7 +47,6 @@ export class AdminPanelComponent {
     if(this.users.find(u => u.id == id)?.isManager){
       roles.push('MANAGER')
     }
-    console.log(roles)
     this.userService.updateUserRole(id, roles)
   }
 

+ 0 - 6
boat-reservation-view/src/app/app.component.ts

@@ -15,12 +15,6 @@ export class AppComponent {
     {code: 'pl', label: 'Polski'}
   ];
 
-  // constructor(translateService: TranslateService) {
-  //   console.log(translateService.data)
-  // }
-  // constructor() {
-  // }
-
   constructor(translate: TranslateService) {
     translate.addLangs(['en', 'klingon', 'pl']);
     translate.setDefaultLang('en');

+ 0 - 2
boat-reservation-view/src/app/footer/footer.component.ts

@@ -17,13 +17,11 @@ export class FooterComponent {
     sessionStorage.setItem('lang', 'en')
     this.lang = sessionStorage.getItem("lang")!
     this.username = sessionStorage.getItem('username')!
-    console.log(this.username)
   }
 
   change_lang(lang: string) {
     sessionStorage.setItem('lang', lang)
     this.translate.use(lang)
     this.lang = lang
-    // console.log("zmiana na ", lang)
   }
 }

+ 0 - 3
boat-reservation-view/src/app/login-view/login-view.component.ts

@@ -34,9 +34,6 @@ export class LoginViewComponent {
       "sub_id": string,
       "sub_role": string
     }
-
-    console.log("login attempt")
-    console.log(this.formData)
     this.authService.login(
       this.formData.get('username')?.value,
       this.formData.get('password')?.value).subscribe(

+ 0 - 9
boat-reservation-view/src/app/manager-panel/manager-panel.component.ts

@@ -32,14 +32,12 @@ export class ManagerPanelComponent {
               private boatService: BoatService) {
     this.reservationService.getReservations().subscribe(
       reservations => {
-        console.log("res1", reservations)
         this.reservations_info = reservations.map(r => {
           r.date = new Date(r.date).toISOString().split("T")[0]
           return r;
         });
         this.boatService.getBoats().subscribe(
           boats => {
-            console.log(boats)
             this.reservations_info.map(r => {
               r.boatId = boats.find(b => b.id == r.boatId)!.name
             })
@@ -48,8 +46,6 @@ export class ManagerPanelComponent {
         )
         this.userService.getAllUsers().subscribe(
           users => {
-            console.log(users)
-            console.log(this.reservations_info)
             this.reservations_info.map(r => {
               if (r.user == undefined) {
                 r.userId = '*deleted*'
@@ -57,11 +53,8 @@ export class ManagerPanelComponent {
                 r.userId = r.user.username
               }
             })
-            console.log(this.reservations_info)
           }
         )
-
-        console.log(reservations[0])
       })
   }
 
@@ -72,8 +65,6 @@ export class ManagerPanelComponent {
 
   confirmReservation(id: number) {
     this.reservationService.confirmReservation(id)
-    console.log(id)
-    console.log(this.reservations_info)
     this.reservations_info.find(r => r.bill.id === id).bill.status = "Confirmed"
   }
 }

+ 0 - 4
boat-reservation-view/src/app/profile-page/profile-page.component.ts

@@ -41,14 +41,12 @@ export class ProfilePageComponent {
             });
             this.boatService.getBoats().subscribe(
               boats => {
-                console.log(boats)
                 this.reservations_info.map(r => {
                   r.boatId = boats.find(b => b.id == r.boatId)!.name
                 })
                 this.reservations_info.sort(this.compareFn)
               }
             )
-            console.log(reservations[0])
           }
         )
       })
@@ -69,8 +67,6 @@ export class ProfilePageComponent {
 
   confirmReservation(id: number) {
     this.reservationService.confirmReservation(id)
-    console.log(id)
-    console.log(this.reservations_info)
     this.reservations_info.find(r => r.bill.id === id).bill.status = "Confirmed"
   }
 

+ 0 - 5
boat-reservation-view/src/app/register-view/register-view.component.ts

@@ -27,22 +27,17 @@ export class RegisterViewComponent {
   }
 
   resolved(captchaResponse: string) {
-    console.log(`Resolved captcha with response: ${captchaResponse}`);
     this.captchaResponse = captchaResponse;
     this.isCaptchaResolved = captchaResponse !== null;
   }
 
   registerUser() {
-    console.log("register attempt")
-    console.log(this.formData)
     this.authService.register(
       this.formData.get('username')?.value,
       this.formData.get('password')?.value,
       this.formData.get('email')?.value,
       this.captchaResponse!).subscribe(
       (response) => {
-        console.log('POST request successful', response);
-
         window.location.href = "http://localhost:1410/"
       },
       async (error) => {

+ 0 - 2
boat-reservation-view/src/app/reservation-view/reservation-view.component.ts

@@ -84,7 +84,6 @@ export class ReservationViewComponent {
       "startHour": this.fromHour,
       "endHour": this.toHour
     }
-    console.log("reservation_info: ", reservation_info)
     this.reservationService.createReservation(reservation_info).subscribe(
       (response) => {
         this.updateSquares()
@@ -154,7 +153,6 @@ export class ReservationViewComponent {
   updateSquares() {
     this.reservationService.findReservations(parseInt(this.boat), this.date).subscribe(
       response => {
-        console.log(response)
         this.reservedHours = response
           .filter(reservation => reservation.bill.status !== 'Cancelled')
           .map(reservation => [reservation.startHour, reservation.endHour])

+ 0 - 2
boat-reservation-view/src/app/services/auth.service.ts

@@ -15,7 +15,6 @@ export class AuthService {
   }
 
   login(username: string, password: string): Observable<any> {
-    console.log("login")
     const url = 'http://localhost:2137/login';
     let loginDto = {
       "username": username,
@@ -29,7 +28,6 @@ export class AuthService {
   }
 
   register(username: string, password: string, email: string, captcha:string): Observable<any> {
-    console.log("register")
     const url = 'http://localhost:2137/register';
     let registerDto = {
       "username": username,