Index: src/main/java/com/example/rezevirajmasa/demo/bootstrap/ReservationInitializer.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/bootstrap/ReservationInitializer.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/bootstrap/ReservationInitializer.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -1,48 +1,48 @@
-package com.example.rezevirajmasa.demo.bootstrap;
-
-import com.example.rezevirajmasa.demo.model.Reservation;
-import com.example.rezevirajmasa.demo.model.Restaurant;
-import com.example.rezevirajmasa.demo.service.ReservationHistoryService;
-import com.example.rezevirajmasa.demo.service.ReservationService;
-import org.springframework.stereotype.Component;
-
-import jakarta.annotation.PostConstruct;
-import java.time.LocalDateTime;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Component
-public class ReservationInitializer {
-    private final ReservationHistoryService reservationHistoryService;
-    private final ReservationService reservationService;
-
-    public ReservationInitializer(ReservationHistoryService reservationHistoryService, ReservationService reservationService) {
-        this.reservationHistoryService = reservationHistoryService;
-        this.reservationService = reservationService;
-    }
-
-    @PostConstruct
-    public void initializePastReservations() {
-        LocalDateTime currentTime = LocalDateTime.now();
-        List<Reservation> reservationsToMove = reservationService.findReservationsToMove(currentTime);
-
-        List<Restaurant.ReservationHistory> reservationHistories = reservationsToMove.stream()
-                .map(reservation -> new Restaurant.ReservationHistory(
-                        reservation.getCustomer(),
-                        reservation.getTable(),
-                        reservation.getRestaurant(),
-                        reservation.getReservationDateTime(),
-                        reservation.getPartySize(),
-                        reservation.getSpecialRequests(),
-                        "Done",
-                        null, // You can set cancellation reason if needed, it's not clear from the code provided
-                        reservation.getCheckInTime() // Use currentTime for check-in date
-                ))
-                .collect(Collectors.toList());
-
-        reservationHistoryService.moveReservationsToPast(reservationHistories);
-
-        reservationsToMove.forEach(reservation -> reservationService.deleteReservation(reservation.getReservationID()));
-    }
-
-}
+//package com.example.rezevirajmasa.demo.bootstrap;
+//
+//import com.example.rezevirajmasa.demo.model.Reservation;
+//import com.example.rezevirajmasa.demo.model.Restaurant;
+//import com.example.rezevirajmasa.demo.service.ReservationHistoryService;
+//import com.example.rezevirajmasa.demo.service.ReservationService;
+//import org.springframework.stereotype.Component;
+//
+//import jakarta.annotation.PostConstruct;
+//import java.time.LocalDateTime;
+//import java.util.List;
+//import java.util.stream.Collectors;
+//
+//@Component
+//public class ReservationInitializer {
+//    private final ReservationHistoryService reservationHistoryService;
+//    private final ReservationService reservationService;
+//
+//    public ReservationInitializer(ReservationHistoryService reservationHistoryService, ReservationService reservationService) {
+//        this.reservationHistoryService = reservationHistoryService;
+//        this.reservationService = reservationService;
+//    }
+//
+//    @PostConstruct
+//    public void initializePastReservations() {
+//        LocalDateTime currentTime = LocalDateTime.now();
+//        List<Reservation> reservationsToMove = reservationService.findReservationsToMove(currentTime);
+//
+//        List<Restaurant.ReservationHistory> reservationHistories = reservationsToMove.stream()
+//                .map(reservation -> new Restaurant.ReservationHistory(
+//                        reservation.getUser(),
+//                        reservation.getTable(),
+//                        reservation.getRestaurant(),
+//                        reservation.getReservationDateTime(),
+//                        reservation.getPartySize(),
+//                        reservation.getSpecialRequests(),
+//                        "Done",
+//                        null,
+//                        reservation.getCheckInTime()
+//                ))
+//                .collect(Collectors.toList());
+//
+//        reservationHistoryService.moveReservationsToPast(reservationHistories);
+//
+//        reservationsToMove.forEach(reservation -> reservationService.deleteReservation(reservation.getReservationID()));
+//    }
+//
+//}
Index: src/main/java/com/example/rezevirajmasa/demo/config/SecurityConfig.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/config/SecurityConfig.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/config/SecurityConfig.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -7,4 +7,5 @@
 import org.springframework.http.HttpMethod;
 import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.Customizer;
 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -15,6 +16,13 @@
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
 import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
+import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
 import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.SecurityFilterChain;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 
@@ -40,33 +48,29 @@
     public void addCorsMappings(CorsRegistry registry) {
         registry.addMapping("/**")
+                .allowedOrigins("http://localhost:3000")
+                .allowedMethods("GET", "POST", "PUT", "DELETE")
+                .allowedHeaders("*")
                 .allowCredentials(true)
-                .allowedOrigins("http://localhost:3000") // Allow requests from this origin
-                .allowedMethods("GET", "POST", "PUT", "DELETE") // Allow these HTTP methods
-                .allowedHeaders("*")
-                .maxAge(3600L); // Allow all headers
+                .maxAge(3600L);
     }
 
 //    @Bean
-//    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception  {
-//
+//    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
 //        http
+//                .exceptionHandling(exception -> exception.authenticationEntryPoint(customerAuthenticationEntryPoint))
+//                .addFilterBefore(new JwtAuthFilter(userAuthProvider), BasicAuthenticationFilter.class)
 //                .csrf(AbstractHttpConfigurer::disable)
-//                .authorizeHttpRequests( (requests) -> requests
-//                        .requestMatchers(AntPathRequestMatcher.antMatcher("/"), AntPathRequestMatcher.antMatcher("/restaurants"))
-//                        .permitAll()
-//                        .anyRequest()
-//                        .hasAnyRole("ADMIN", "USER")
+//                .sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
+//                .authorizeHttpRequests(requests -> requests
+//                        .requestMatchers(HttpMethod.POST, "/api/login", "/api/register").permitAll()
+//                        .requestMatchers("/", "/home").authenticated()  // Restrict `/` to authenticated users
+//                        .anyRequest().authenticated()
 //                )
-//                .formLogin((form) -> form
-//                        .permitAll()
-//                        .failureUrl("/login?error=BadCredentials")
-//                        .defaultSuccessUrl("/restaurants", true)
-//                )
-//                .logout((logout) -> logout
+//                .logout(logout -> logout
 //                        .logoutUrl("/logout")
 //                        .clearAuthentication(true)
 //                        .invalidateHttpSession(true)
 //                        .deleteCookies("JSESSIONID")
-//                        .logoutSuccessUrl("/")
+//                        .logoutSuccessUrl("/api/login")  // Redirect to login page after logout
 //                );
 //
@@ -83,8 +87,8 @@
                 .authorizeHttpRequests((requests) -> requests
                         .requestMatchers(HttpMethod.POST, "/api/login", "/api/register").permitAll()
-                        .anyRequest().authenticated()
-                );
+                        .anyRequest().authenticated());
         return http.build();
     }
+
     @Bean
     public AuthenticationManager authManager(HttpSecurity http) throws Exception {
@@ -95,2 +99,50 @@
     }
 }
+//
+//import com.example.rezevirajmasa.demo.web.filters.JwtAuthFilter;
+//import org.springframework.context.annotation.Bean;
+//import org.springframework.context.annotation.Configuration;
+//import org.springframework.security.authentication.AuthenticationManager;
+//import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+//import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+//import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
+//import org.springframework.security.config.http.SessionCreationPolicy;
+//import org.springframework.security.core.userdetails.UserDetailsService;
+//import org.springframework.security.web.SecurityFilterChain;
+//import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+//
+//@Configuration
+//@EnableWebSecurity
+//public class SecurityConfig {
+//
+//    private final UserDetailsService userDetailsService;
+////    private final UserAuthProvider userAuthProvider;
+//    private final JwtAuthFilter jwtAuthFilter;
+//
+//    public SecurityConfig(UserDetailsService userDetailsService) {
+//        this.userDetailsService = userDetailsService;
+////        this.userAuthProvider = userAuthProvider;
+//        this.jwtAuthFilter = new JwtAuthFilter(userAuthProvider);
+//    }
+//
+//    @Bean
+//    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
+//        http
+//                .csrf(AbstractHttpConfigurer::disable)
+//                .sessionManagement(sess -> sess.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
+//                .authorizeHttpRequests((requests) -> requests
+//                        .requestMatchers("/api/login", "/api/register").permitAll()
+//                        .anyRequest().authenticated())
+//                .addFilterBefore(jwtAuthFilter, UsernamePasswordAuthenticationFilter.class);
+//
+//        return http.build();
+//    }
+//
+//    @Bean
+//    public AuthenticationManager authenticationManager(HttpSecurity http) throws Exception {
+//        AuthenticationManagerBuilder authenticationManagerBuilder = http.getSharedObject(AuthenticationManagerBuilder.class);
+//        authenticationManagerBuilder.userDetailsService(userDetailsService);
+//        return authenticationManagerBuilder.build();
+//    }
+//}
Index: src/main/java/com/example/rezevirajmasa/demo/config/UserAuthProvider.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/config/UserAuthProvider.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/config/UserAuthProvider.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -7,4 +7,6 @@
 import com.example.rezevirajmasa.demo.dto.UserDto;
 import com.example.rezevirajmasa.demo.service.UserService;
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jwts;
 import jakarta.annotation.PostConstruct;
 import lombok.RequiredArgsConstructor;
@@ -12,9 +14,9 @@
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.Authentication;
+import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.stereotype.Component;
 
-import java.util.Base64;
-import java.util.Collections;
-import java.util.Date;
+import java.util.*;
+import java.util.function.Function;
 
 @RequiredArgsConstructor
@@ -29,4 +31,9 @@
     protected void init() {
         secretKey = Base64.getEncoder().encodeToString(secretKey.getBytes());
+    }
+
+    public String generateToken(UserDetails userDetails){
+        Map<String, Object> claims = new HashMap<>();
+        return createToken(userDetails.getUsername());
     }
 
@@ -50,3 +57,24 @@
         return new UsernamePasswordAuthenticationToken(user, null, Collections.emptyList());
     }
+
+    public String extractUsername(String token) {
+        return extractClaim(token, Claims::getSubject);
+    }
+
+    public Date extractExpiration(String token) {
+        return extractClaim(token, Claims::getExpiration);
+    }
+
+    public <T> T extractClaim(String token, Function<Claims, T> claimsResolver) {
+        final Claims claims = extractAllClaims(token);
+        return claimsResolver.apply(claims);
+    }
+
+    private Claims extractAllClaims(String token) {
+        return Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token).getBody();
+    }
+
+    private Boolean isTokenExpired(String token) {
+        return extractExpiration(token).before(new Date());
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/dto/CredentialsDto.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/dto/CredentialsDto.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/dto/CredentialsDto.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -11,5 +11,5 @@
 @Data
 public class CredentialsDto {
-    private String login;
+    private String email;
     private char[] password;
 }
Index: src/main/java/com/example/rezevirajmasa/demo/dto/SignUpDto.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/dto/SignUpDto.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/dto/SignUpDto.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -15,3 +15,6 @@
     private String email;
     private char[] password;
+    private String phone;
+    private String address;
+    private String membershipLevel;
 }
Index: src/main/java/com/example/rezevirajmasa/demo/dto/UserDto.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/dto/UserDto.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/dto/UserDto.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -16,3 +16,6 @@
     private String email;
     private String token;
+    private String phone;
+    private String address;
+    private String membershipLevel;
 }
Index: src/main/java/com/example/rezevirajmasa/demo/mappers/UserMapper.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/mappers/UserMapper.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/mappers/UserMapper.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -14,3 +14,6 @@
     @Mapping(target = "password", ignore = true)
     User signUpToUser(SignUpDto userDto);
+
+    SignUpDto toSignUpDto(UserDto userDto);
+    User toUser(UserDto userDto);
 }
Index: src/main/java/com/example/rezevirajmasa/demo/mappers/UserMapperImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/mappers/UserMapperImpl.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/mappers/UserMapperImpl.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -3,4 +3,5 @@
 import com.example.rezevirajmasa.demo.dto.SignUpDto;
 import com.example.rezevirajmasa.demo.dto.UserDto;
+import com.example.rezevirajmasa.demo.model.MembershipLevel;
 import com.example.rezevirajmasa.demo.model.User;
 import org.springframework.stereotype.Component;
@@ -36,5 +37,41 @@
         user.setFirstName(userDto.getFirstName());
         user.setLastName(userDto.getLastName());
-        user.setPassword(Arrays.toString(userDto.getPassword()));
+        user.setPassword(Arrays.toString(userDto.getPassword())); // Assuming password is a char[] or string array.
+
+        return user;
+    }
+
+    @Override
+    public SignUpDto toSignUpDto(UserDto userDto) {
+        if (userDto == null) {
+            return null;
+        }
+
+        SignUpDto signUpDto = new SignUpDto();
+        signUpDto.setEmail(userDto.getEmail());
+        signUpDto.setFirstName(userDto.getFirstName());
+        signUpDto.setLastName(userDto.getLastName());
+
+        // Since SignUpDto has password field, you may set it if needed.
+        // Assuming a default value or handling empty password as required.
+        signUpDto.setPassword(new char[0]); // Empty password for now or assign actual value if required.
+
+        return signUpDto;
+    }
+
+    @Override
+    public User toUser(UserDto userDto) {
+        if(userDto == null) {
+            return null;
+        }
+
+        User user = new User();
+        user.setLastName(userDto.getLastName());
+        user.setFirstName(userDto.getFirstName());
+        user.setPhone(userDto.getPhone());
+        user.setMembershipLevel(MembershipLevel.valueOf(userDto.getMembershipLevel()));
+        user.setAddress(userDto.getAddress());
+        user.setEmail(userDto.getEmail());
+        user.setId(userDto.getId());
 
         return user;
Index: src/main/java/com/example/rezevirajmasa/demo/model/Reservation.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/model/Reservation.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/model/Reservation.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -16,6 +16,6 @@
 
     @ManyToOne
-    @JoinColumn(name = "CustomerID")
-    private Customer customer;
+    @JoinColumn(name = "UserID")
+    private User user;
 
     @ManyToOne
@@ -68,7 +68,8 @@
     }
 
-    public Reservation(Customer customer, TableEntity table, Restaurant restaurant, LocalDateTime reservationDateTime, int partySize, String specialRequests, String status, LocalDateTime checkInTime, LocalDateTime checkOutTime, String paymentStatus) {
+    public Reservation(User user, TableEntity table, Restaurant restaurant, LocalDateTime reservationDateTime, int partySize, String specialRequests, String status, LocalDateTime checkInTime, LocalDateTime checkOutTime, String paymentStatus) {
 //        this.customer = customer;
         this.table = table;
+        this.user = user;
         this.restaurant = restaurant;
         this.reservationDateTime = reservationDateTime;
@@ -81,4 +82,12 @@
     }
 
+    public User getUser() {
+        return user;
+    }
+
+    public void setUser(User user) {
+        this.user = user;
+    }
+
     public Long getReservationID() {
         return reservationID;
@@ -89,11 +98,4 @@
     }
 
-    public Customer getCustomer() {
-        return customer;
-    }
-
-    public void setCustomer(Customer customer) {
-        this.customer = customer;
-    }
 
     public TableEntity getTable() {
@@ -173,5 +175,5 @@
         return "Reservation{" +
                 "reservationID=" + reservationID +
-                ", customer=" + customer +
+                ", customer=" + user +
                 ", table=" + table +
                 ", restaurant=" + restaurant +
Index: src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/model/Restaurant.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -151,5 +151,5 @@
         @ManyToOne
         @JoinColumn(name = "customer_id")
-        private Customer customer;
+        private User user;
 
         @ManyToOne
@@ -179,6 +179,6 @@
         private LocalDateTime checkInDate;
 
-        public ReservationHistory(Customer customer, TableEntity table, Restaurant restaurant, LocalDateTime reservationDateTime, int partySize, String specialRequests, String status, String cancellationReason, LocalDateTime checkInDate) {
-            this.customer = customer;
+        public ReservationHistory(User user, TableEntity table, Restaurant restaurant, LocalDateTime reservationDateTime, int partySize, String specialRequests, String status, String cancellationReason, LocalDateTime checkInDate) {
+            this.user = user;
             this.table = table;
             this.restaurant = restaurant;
@@ -202,10 +202,10 @@
         }
 
-        public Customer getCustomer() {
-            return customer;
-        }
-
-        public void setCustomer(Customer customer) {
-            this.customer = customer;
+        public User getUser() {
+            return user;
+        }
+
+        public void setUser(User user) {
+            this.user = user;
         }
 
@@ -278,5 +278,5 @@
             return "ReservationHistory{" +
                     "id=" + id +
-                    ", customer=" + customer +
+                    ", user=" + user +
                     ", table=" + table +
                     ", restaurant=" + restaurant +
Index: src/main/java/com/example/rezevirajmasa/demo/model/User.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/model/User.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/model/User.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -7,4 +7,6 @@
 import lombok.NoArgsConstructor;
 import org.springframework.web.bind.annotation.GetMapping;
+
+import java.util.Date;
 
 @AllArgsConstructor
@@ -31,3 +33,20 @@
     @Column(nullable = false)
     private String password;
+
+    @Enumerated(EnumType.STRING)
+    private Role role;
+
+    @Column(name = "Phone", length = 20)
+    private String phone;
+
+    @Column(name = "Address", columnDefinition = "TEXT")
+    private String address;
+
+    @Enumerated(EnumType.STRING)
+    @Column(name = "MembershipLevel", length = 20)
+    private MembershipLevel membershipLevel;
+
+    @Column(name = "RegistrationDate", columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
+    @Temporal(TemporalType.TIMESTAMP)
+    private Date registrationDate;
 }
Index: src/main/java/com/example/rezevirajmasa/demo/repository/ReservationHistoryRepository.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/repository/ReservationHistoryRepository.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/repository/ReservationHistoryRepository.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -4,4 +4,5 @@
 import com.example.rezevirajmasa.demo.model.Reservation;
 import com.example.rezevirajmasa.demo.model.Restaurant;
+import com.example.rezevirajmasa.demo.model.User;
 import org.springframework.cglib.core.Local;
 import org.springframework.data.jpa.repository.JpaRepository;
@@ -11,5 +12,5 @@
 
 public interface ReservationHistoryRepository extends JpaRepository<Restaurant.ReservationHistory, Long> {
-    List<Restaurant.ReservationHistory> findAllByCustomer(Customer customer);
+    List<Restaurant.ReservationHistory> findALlByUser(User user);
     List<Restaurant.ReservationHistory> findByCheckInDateBeforeAndStatus(LocalDateTime currentTime, String scheduled);
     List<Restaurant.ReservationHistory> findAllByCheckInDateBefore(LocalDateTime currentTime);
Index: src/main/java/com/example/rezevirajmasa/demo/repository/ReservationRepository.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/repository/ReservationRepository.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/repository/ReservationRepository.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -1,8 +1,5 @@
 package com.example.rezevirajmasa.demo.repository;
 
-import com.example.rezevirajmasa.demo.model.Customer;
-import com.example.rezevirajmasa.demo.model.Reservation;
-import com.example.rezevirajmasa.demo.model.Restaurant;
-import com.example.rezevirajmasa.demo.model.TableEntity;
+import com.example.rezevirajmasa.demo.model.*;
 import org.springframework.data.jpa.repository.JpaRepository;
 
@@ -11,5 +8,5 @@
 
 public interface ReservationRepository extends JpaRepository<Reservation, Long> {
-    List<Reservation> findAllByCustomer(Customer customer);
+    List<Reservation> findALlByUserAndCheckInTimeAfter(User user, LocalDateTime now);
     List<Reservation> findByTableAndCheckInTimeBetween(TableEntity table, LocalDateTime startTime, LocalDateTime endTime);
 
@@ -17,3 +14,4 @@
     List<Reservation> findAllByCheckInTimeBefore(LocalDateTime currentTime);
     List<Reservation> findByCheckInTimeAfterAndCheckInTimeBefore(LocalDateTime startTime, LocalDateTime endTime);
+    List<Reservation> findALlByUserAndCheckInTimeBefore(User user, LocalDateTime now);
 }
Index: src/main/java/com/example/rezevirajmasa/demo/service/ReservationHistoryService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/ReservationHistoryService.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/service/ReservationHistoryService.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -4,4 +4,5 @@
 import com.example.rezevirajmasa.demo.model.Reservation;
 import com.example.rezevirajmasa.demo.model.Restaurant;
+import com.example.rezevirajmasa.demo.model.User;
 
 import java.time.LocalDateTime;
@@ -11,5 +12,5 @@
     public void moveReservationToHistory(Reservation reservation, String status, String cancellationReason);
     public void moveReservationsToPast(List<Restaurant.ReservationHistory> reservationsToMove);
-    List<Restaurant.ReservationHistory> findByCustomer(Customer customer);
+    List<Restaurant.ReservationHistory> findByUser(User user);
     List<Restaurant.ReservationHistory> findAll();
     List<Restaurant.ReservationHistory> findReservationsToMove(LocalDateTime currentTime);
Index: src/main/java/com/example/rezevirajmasa/demo/service/ReservationSchedulerService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/ReservationSchedulerService.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
+++ src/main/java/com/example/rezevirajmasa/demo/service/ReservationSchedulerService.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -0,0 +1,34 @@
+package com.example.rezevirajmasa.demo.service;
+
+import com.example.rezevirajmasa.demo.model.Reservation;
+import com.example.rezevirajmasa.demo.repository.ReservationRepository;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Service;
+
+import java.time.LocalDateTime;
+import java.util.List;
+
+@Service
+public class ReservationSchedulerService {
+
+    private final ReservationRepository reservationRepository;
+    private final ReservationHistoryService reservationHistoryService;
+
+    public ReservationSchedulerService(
+            ReservationRepository reservationRepository,
+            ReservationHistoryService reservationHistoryService) {
+        this.reservationRepository = reservationRepository;
+        this.reservationHistoryService = reservationHistoryService;
+    }
+
+    @Scheduled(cron = "0 0 0 * * ?")
+    public void archivePastReservations() {
+        LocalDateTime now = LocalDateTime.now();
+        List<Reservation> pastReservations = reservationRepository.findAllByCheckInTimeBefore(now);
+
+        for (Reservation reservation : pastReservations) {
+            reservationHistoryService.moveReservationToHistory(reservation, "Past", null);
+            reservationRepository.delete(reservation);
+        }
+    }
+}
Index: src/main/java/com/example/rezevirajmasa/demo/service/ReservationService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/ReservationService.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/service/ReservationService.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -1,8 +1,6 @@
 package com.example.rezevirajmasa.demo.service;
 
-import com.example.rezevirajmasa.demo.model.Customer;
-import com.example.rezevirajmasa.demo.model.Reservation;
-import com.example.rezevirajmasa.demo.model.Restaurant;
-import com.example.rezevirajmasa.demo.model.TableEntity;
+import com.example.rezevirajmasa.demo.model.*;
+import org.springframework.security.core.userdetails.UserDetails;
 
 import java.time.LocalDateTime;
@@ -10,11 +8,12 @@
 
 public interface ReservationService {
-    public void makeReservation(Customer customer, TableEntity table, Restaurant restaurant, LocalDateTime localDateTime, LocalDateTime checkInTime, int partySize, String specialRequests);
-    public Reservation makeReservationRest(Reservation reservation);
+    public void makeReservation(User user, TableEntity table, Restaurant restaurant, LocalDateTime localDateTime, LocalDateTime checkInTime, int partySize, String specialRequests);
+    public Reservation makeReservationRest(Reservation reservation, User user);
     public List<Reservation> listAll();
     public Reservation findById(Long id);
     public Reservation getReservationById(Long reservationId);
     public boolean cancelReservation(Long reservationId);
-    public List<Reservation> findReservationByCustomer(Customer customer);
+    public List<Reservation> findReservationByUser(User user);
+    public List<Reservation> findReservationsByUserPast(User user);
     public List<Reservation> findReservationsByTableAndDateRange(TableEntity table, LocalDateTime startDateTime, LocalDateTime endDateTime);
     List<Reservation> findReservationsToMove(LocalDateTime currentTime);
Index: src/main/java/com/example/rezevirajmasa/demo/service/UserService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/UserService.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/service/UserService.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -4,4 +4,5 @@
 import com.example.rezevirajmasa.demo.dto.SignUpDto;
 import com.example.rezevirajmasa.demo.dto.UserDto;
+import com.example.rezevirajmasa.demo.model.User;
 import lombok.RequiredArgsConstructor;
 
@@ -9,5 +10,7 @@
 public interface UserService {
     public UserDto findByEmail(String email);
+    public User findByMail(String email);
     public UserDto login(CredentialsDto credentialsDto);
     public UserDto register(SignUpDto userDto);
+    public User findUserById(Long userId);
 }
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationHistoryServiceImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationHistoryServiceImpl.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationHistoryServiceImpl.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -4,4 +4,5 @@
 import com.example.rezevirajmasa.demo.model.Reservation;
 import com.example.rezevirajmasa.demo.model.Restaurant;
+import com.example.rezevirajmasa.demo.model.User;
 import com.example.rezevirajmasa.demo.repository.ReservationHistoryRepository;
 import com.example.rezevirajmasa.demo.service.ReservationHistoryService;
@@ -22,5 +23,5 @@
     public void moveReservationToHistory(Reservation reservation, String status, String cancellationReason) {
         Restaurant.ReservationHistory history = new Restaurant.ReservationHistory();
-        history.setCustomer(reservation.getCustomer());
+        history.setUser(reservation.getUser());
         history.setTable(reservation.getTable());
         history.setReservationDateTime(reservation.getReservationDateTime());
@@ -42,16 +43,14 @@
 
     @Override
-    public List<Restaurant.ReservationHistory> findByCustomer(Customer customer) {
-        return reservationHistoryRepository.findAllByCustomer(customer);
+    public List<Restaurant.ReservationHistory> findByUser(User user) {
+        return reservationHistoryRepository.findALlByUser(user);
     }
 
     @Override
     public void moveReservationsToPast(List<Restaurant.ReservationHistory> reservationsToMove) {
-        // Update the status of reservations to "Past"
         for (Restaurant.ReservationHistory reservation : reservationsToMove) {
             reservation.setStatus("Past");
         }
 
-        // Save the updated reservations
         reservationHistoryRepository.saveAll(reservationsToMove);
     }
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationImpl.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/ReservationImpl.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -1,8 +1,7 @@
 package com.example.rezevirajmasa.demo.service.impl;
 
-import com.example.rezevirajmasa.demo.model.Customer;
-import com.example.rezevirajmasa.demo.model.Reservation;
-import com.example.rezevirajmasa.demo.model.Restaurant;
-import com.example.rezevirajmasa.demo.model.TableEntity;
+import com.example.rezevirajmasa.demo.dto.UserDto;
+import com.example.rezevirajmasa.demo.mappers.UserMapper;
+import com.example.rezevirajmasa.demo.model.*;
 import com.example.rezevirajmasa.demo.model.exceptions.InvalidReservationException;
 import com.example.rezevirajmasa.demo.model.exceptions.InvalidReservationIdException;
@@ -11,7 +10,15 @@
 import com.example.rezevirajmasa.demo.repository.RestaurantRepository;
 import com.example.rezevirajmasa.demo.repository.TableRepository;
+import com.example.rezevirajmasa.demo.service.ReservationHistoryService;
 import com.example.rezevirajmasa.demo.service.ReservationService;
+import com.example.rezevirajmasa.demo.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cglib.core.Local;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.stereotype.Service;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import javax.swing.text.html.Option;
@@ -27,9 +34,14 @@
     private TableRepository tableRepository;
     @Autowired
-    private RestaurantRepository restaurantRepository;
+    private ReservationHistoryService reservationHistoryService;
+    private final UserMapper userMapper;
     @Autowired
-    private CustomerRepository customerRepository;
+    private UserService userService;
     @Autowired
     private ReservationRepository reservationRepository;
+
+    public ReservationImpl(UserMapper userMapper) {
+        this.userMapper = userMapper;
+    }
 
     @Override
@@ -39,5 +51,5 @@
 
     @Override
-    public void makeReservation(Customer customer, TableEntity table, Restaurant restaurant, LocalDateTime localDateTime, LocalDateTime checkInTime, int partySize, String specialRequests) {
+    public void makeReservation(User user, TableEntity table, Restaurant restaurant, LocalDateTime localDateTime, LocalDateTime checkInTime, int partySize, String specialRequests) {
         if (!table.isAvailable(checkInTime)) {
             // Handle unavailability (throw an exception, return a specific response, etc.)
@@ -46,5 +58,5 @@
 
         Reservation reservation =
-                new Reservation(customer, table, restaurant, LocalDateTime.now(), partySize, specialRequests, "Reserved", checkInTime, checkInTime.plusHours(2), null);
+                new Reservation(user, table, restaurant, LocalDateTime.now(), partySize, specialRequests, "Reserved", checkInTime, checkInTime.plusHours(2), null);
 
 //        // Update table status or perform additional logic if needed
@@ -56,8 +68,10 @@
 
     @Override
-    public Reservation makeReservationRest(Reservation reservation) {
+    public Reservation makeReservationRest(Reservation reservation, User user) {
         Optional<TableEntity> optionalTable = tableRepository.findById(reservation.getTable().getId());
-        if(optionalTable.isPresent()) {
+        if (optionalTable.isPresent()) {
             TableEntity table = optionalTable.get();
+
+            reservation.setUser(user);
 
             LocalDateTime startTime = reservation.getCheckInTime().minusHours(2);
@@ -67,10 +81,11 @@
                     x -> x.isAfter(startTime) && x.isBefore(endTime)
             );
-
+            reservation.setReservationDateTime(LocalDateTime.now());
             return reservationRepository.save(reservation);
         } else {
-            throw new InvalidReservationException("Unsuccessful reservation -> time slot not avalaible");
+            throw new InvalidReservationException("Unsuccessful reservation -> time slot not available");
         }
     }
+
 
     @Override
@@ -109,8 +124,9 @@
                 from = from.plusMinutes(15);
             }
+            reservationHistoryService.moveReservationToHistory(reservation, "Canceled", "Canceled by user");
             reservationRepository.delete(reservation);
-            return true; // Return true indicating successful cancellation
+            return true;
         } else {
-            return false; // Return false indicating reservation with the given ID not found
+            return false;
         }
     }
@@ -118,6 +134,13 @@
 
     @Override
-    public List<Reservation> findReservationByCustomer(Customer customer) {
-        return reservationRepository.findAllByCustomer(customer);
+    public List<Reservation> findReservationByUser(User user) {
+        LocalDateTime now = LocalDateTime.now();
+        return reservationRepository.findALlByUserAndCheckInTimeAfter(user, now);
+    }
+
+    @Override
+    public List<Reservation> findReservationsByUserPast(User user) {
+        LocalDateTime now = LocalDateTime.now();
+        return reservationRepository.findALlByUserAndCheckInTimeBefore(user, now);
     }
 
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/RestaurantServiceImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/RestaurantServiceImpl.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/RestaurantServiceImpl.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -175,5 +175,6 @@
                     .collect(Collectors.toList());
         } else {
-            List<Restaurant> restaurantList = restaurantRepository.findAllByNameLikeIgnoreCase(search);
+            String searchTerm = "%" + search + "%";
+            List<Restaurant> restaurantList = restaurantRepository.findAllByNameLikeIgnoreCase(searchTerm);
             if (restaurantList.isEmpty()) {
                 restaurantList = restaurantRepository.findAllByCuisineTypeContaining(search);
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/TokenService.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/TokenService.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/TokenService.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -0,0 +1,34 @@
+package com.example.rezevirajmasa.demo.service.impl;
+
+import com.example.rezevirajmasa.demo.config.security.SecurityConstants;
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.ExpiredJwtException;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TokenService {
+
+    public String getUserIdFromToken(String token) {
+        try {
+            String jwtToken = token.substring(7);
+
+            Claims claims = Jwts.parser()
+                    .setSigningKey(SecurityConstants.SECRET)
+                    .parseClaimsJws(jwtToken)
+                    .getBody();
+
+            return claims.getSubject();  // Assumes 'sub' claim contains user ID
+        } catch (ExpiredJwtException e) {
+            throw new RuntimeException("Token has expired", e);
+        } catch (SignatureException e) {
+            throw new RuntimeException("Invalid token signature", e);
+        } catch (IllegalArgumentException e) {
+            throw new RuntimeException("Invalid token format", e);
+        } catch (Exception e) {
+            throw new RuntimeException("Could not extract user ID from token", e);
+        }
+    }
+}
Index: src/main/java/com/example/rezevirajmasa/demo/service/impl/UserServiceImpl.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/service/impl/UserServiceImpl.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/service/impl/UserServiceImpl.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -6,4 +6,6 @@
 import com.example.rezevirajmasa.demo.mappers.UserMapper;
 import com.example.rezevirajmasa.demo.mappers.UserMapperImpl;
+import com.example.rezevirajmasa.demo.model.MembershipLevel;
+import com.example.rezevirajmasa.demo.model.Role;
 import com.example.rezevirajmasa.demo.model.User;
 import com.example.rezevirajmasa.demo.model.exceptions.AppException;
@@ -12,8 +14,11 @@
 import lombok.RequiredArgsConstructor;
 import org.mapstruct.control.MappingControl;
+import org.openqa.selenium.InvalidArgumentException;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.stereotype.Service;
 import java.nio.CharBuffer;
+import java.sql.Date;
+import java.time.LocalDate;
 import java.util.Optional;
 
@@ -30,6 +35,11 @@
     }
 
+    @Override
+    public User findByMail(String email) {
+        return userRepository.findByEmail(email).orElseThrow(() -> new AppException(("Unknown user"), HttpStatus.NOT_FOUND));
+    }
+
     public UserDto login(CredentialsDto credentialsDto) {
-        User user = userRepository.findByEmail(credentialsDto.getLogin())
+        User user = userRepository.findByEmail(credentialsDto.getEmail())
                 .orElseThrow(() -> new AppException("Unknown user", HttpStatus.NOT_FOUND));
 
@@ -51,7 +61,20 @@
         user.setPassword(passwordEncoder.encode(CharBuffer.wrap(userDto.getPassword())));
 
+        user.setFirstName(userDto.getFirstName());
+        user.setLastName(userDto.getLastName());
+        user.setAddress(userDto.getAddress());
+        user.setPhone(userDto.getPhone());
+        user.setMembershipLevel(MembershipLevel.valueOf(userDto.getMembershipLevel()));
+        user.setRegistrationDate(Date.valueOf(LocalDate.now()));
+        user.setRole(Role.ROLE_USER);
+
         User savedUser = userRepository.save(user);
 
-        return userMapper.toUserDto(user);
+        return userMapper.toUserDto(savedUser);
+    }
+
+    @Override
+    public User findUserById(Long userId) {
+        return userRepository.findById(userId).orElseThrow(()->new InvalidArgumentException("Invalid user Id"));
     }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/web/controller/ReservationController.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/web/controller/ReservationController.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/web/controller/ReservationController.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -1,4 +1,7 @@
 package com.example.rezevirajmasa.demo.web.controller;
 
+import com.example.rezevirajmasa.demo.dto.SignUpDto;
+import com.example.rezevirajmasa.demo.dto.UserDto;
+import com.example.rezevirajmasa.demo.mappers.UserMapper;
 import com.example.rezevirajmasa.demo.model.*;
 import com.example.rezevirajmasa.demo.model.exceptions.ExpiredReservationException;
@@ -19,28 +22,33 @@
 public class ReservationController {
     private final ReservationService reservationService;
-    private final CustomerService customerService;
+    private final UserService userService;
     private final TableService tableService;
     private final ReservationHistoryService reservationHistoryService;
 
-    public ReservationController(ReservationService reservationService, CustomerService customerService, TableService tableService, ReservationHistoryService reservationHistoryService) {
+    private final UserMapper userMapper;
+
+    public ReservationController(ReservationService reservationService, UserService userService, TableService tableService, ReservationHistoryService reservationHistoryService, UserMapper userMapper) {
         this.reservationService = reservationService;
-        this.customerService = customerService;
+        this.userService = userService;
         this.tableService = tableService;
         this.reservationHistoryService = reservationHistoryService;
+        this.userMapper = userMapper;
     }
 
     @GetMapping("/reservations")
     public String showReservations(Model model, Authentication authentication) {
-        Customer customer = customerService.findByEmail(authentication.getName());
-        List<Reservation> reservationList;
-        if(customer.getRole().equals(Role.ROLE_ADMIN)) {
-            reservationList = reservationService.listAll();
-        } else {
-            reservationList = reservationService.findReservationByCustomer(customer);
-        }
+        UserDto userDto = userService.findByEmail(authentication.getName());
+
+        SignUpDto signUpDto = userMapper.toSignUpDto(userDto);
+
+        User user = userMapper.signUpToUser(signUpDto);
+
+        List<Reservation> reservationList = reservationService.findReservationByUser(user);
+
         model.addAttribute("bodyContent", "reservationList");
         model.addAttribute("reservations", reservationList);
         return "index";
     }
+
 
     @GetMapping("/reservations/edit/{reservationId}")
@@ -62,5 +70,9 @@
         Restaurant restaurant = table.getRestaurant();
 
-        Customer customer = customerService.findByEmail(authentication.getName());
+        UserDto userDto = userService.findByEmail(authentication.getName());
+
+        SignUpDto signUpDto = userMapper.toSignUpDto(userDto);
+
+        User user = userMapper.signUpToUser(signUpDto);
 
         if(!table.isAvailable(reservationDateTime)) {
@@ -68,5 +80,5 @@
         }
         tableService.deleteTimeSlotsForReservation(tableNumber, reservationDateTime);
-        reservationService.makeReservation(customer, table, restaurant, LocalDateTime.now(), reservationDateTime, partySize, specialRequests);
+        reservationService.makeReservation(user, table, restaurant, LocalDateTime.now(), reservationDateTime, partySize, specialRequests);
         return "redirect:/reservations";
     }
Index: src/main/java/com/example/rezevirajmasa/demo/web/controller/ReservationHistoryController.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/web/controller/ReservationHistoryController.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/web/controller/ReservationHistoryController.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -1,9 +1,14 @@
 package com.example.rezevirajmasa.demo.web.controller;
 
+import com.example.rezevirajmasa.demo.dto.SignUpDto;
+import com.example.rezevirajmasa.demo.dto.UserDto;
+import com.example.rezevirajmasa.demo.mappers.UserMapper;
 import com.example.rezevirajmasa.demo.model.Customer;
 import com.example.rezevirajmasa.demo.model.Restaurant;
 import com.example.rezevirajmasa.demo.model.Role;
+import com.example.rezevirajmasa.demo.model.User;
 import com.example.rezevirajmasa.demo.service.CustomerService;
 import com.example.rezevirajmasa.demo.service.ReservationHistoryService;
+import com.example.rezevirajmasa.demo.service.UserService;
 import org.springframework.security.core.Authentication;
 import org.springframework.stereotype.Controller;
@@ -18,9 +23,11 @@
 public class ReservationHistoryController {
     private final ReservationHistoryService reservationHistoryService;
-    private final CustomerService customerService;
+    private final UserService userService;
+    private final UserMapper userMapper;
 
-    public ReservationHistoryController(ReservationHistoryService reservationHistoryService, CustomerService customerService) {
+    public ReservationHistoryController(ReservationHistoryService reservationHistoryService, UserService userService, UserMapper userMapper) {
         this.reservationHistoryService = reservationHistoryService;
-        this.customerService = customerService;
+        this.userService = userService;
+        this.userMapper = userMapper;
     }
 
@@ -28,10 +35,16 @@
     public String showPastReservations(Authentication authentication, Model model) {
         List<Restaurant.ReservationHistory> reservationHistoryList;
-        Customer customer = customerService.findByEmail(authentication.getName());
-        if(customer.getRole().equals(Role.ROLE_ADMIN)) {
-            reservationHistoryList = reservationHistoryService.findAll();
-        } else {
-            reservationHistoryList = reservationHistoryService.findByCustomer(customer);
-        }
+        UserDto userDto = userService.findByEmail(authentication.getName());
+
+        SignUpDto signUpDto = userMapper.toSignUpDto(userDto);
+
+        User user = userMapper.signUpToUser(signUpDto);
+
+        reservationHistoryList = reservationHistoryService.findByUser(user);
+//        if(customer.getRole().equals(Role.ROLE_ADMIN)) {
+//            reservationHistoryList = reservationHistoryService.findAll();
+//        } else {
+//            reservationHistoryList = reservationHistoryService.findByUser(User user);
+//        }
         model.addAttribute("historyReservations", reservationHistoryList);
         model.addAttribute("bodyContent", "pastReservations");
Index: src/main/java/com/example/rezevirajmasa/demo/web/filters/JwtAuthFilter.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/web/filters/JwtAuthFilter.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/web/filters/JwtAuthFilter.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -2,4 +2,5 @@
 
 import com.example.rezevirajmasa.demo.config.UserAuthProvider;
+import io.jsonwebtoken.ExpiredJwtException;
 import jakarta.servlet.FilterChain;
 import jakarta.servlet.ServletException;
@@ -7,5 +8,7 @@
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.RequiredArgsConstructor;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpHeaders;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.web.filter.OncePerRequestFilter;
@@ -17,4 +20,5 @@
 
     private final UserAuthProvider userAuthProvider;
+
     @Override
     protected void doFilterInternal(
@@ -24,12 +28,31 @@
         String header = request.getHeader(HttpHeaders.AUTHORIZATION);
 
+        String username = null;
+        String jwt = null;
+
         if(header != null) {
+            jwt = header.substring(7);
             String[] elements = header.split(" ");
 
             if(elements.length == 2 && "Bearer".equals(elements[0])) {
                 try {
+                    username = userAuthProvider.extractUsername(jwt); // logikata vidi ja
                     SecurityContextHolder.getContext().setAuthentication(
                             userAuthProvider.validateToken(elements[1])
                     );
+                    if (username != null) {
+                        System.out.println("Authenticated user: " + username); // Debug log
+                        SecurityContextHolder.getContext().setAuthentication(
+                                userAuthProvider.validateToken(jwt) // Ensure token validation works properly
+                        );
+                    }
+                } catch (ExpiredJwtException e) {
+                    String isRefreshToken = request.getHeader("isRefreshToken");
+                    String requestURL = request.getRequestURL().toString();
+                    if (isRefreshToken != null && isRefreshToken.equals("true") && requestURL.contains("refresh-token")) {
+                        allowForRefreshToken(e, request);
+                    } else
+                        request.setAttribute("exception", e);
+
                 } catch (RuntimeException e) {
                     SecurityContextHolder.clearContext();
@@ -40,3 +63,10 @@
         filterChain.doFilter(request, response);
     }
+
+    private void allowForRefreshToken(ExpiredJwtException ex, HttpServletRequest request) {
+        UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(
+                null, null, null);
+        SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
+        request.setAttribute("claims", ex.getClaims());
+    }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/web/rest/AuthController.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/web/rest/AuthController.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/web/rest/AuthController.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -14,4 +14,6 @@
 import org.springframework.http.ResponseEntity;
 import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.web.bind.annotation.CrossOrigin;
@@ -30,5 +32,7 @@
     public ResponseEntity<UserDto> login(@RequestBody CredentialsDto credentialsDto) {
         UserDto user = userService.login(credentialsDto);
-        user.setToken(userAuthProvider.createToken(user.getEmail()));
+        String token = userAuthProvider.createToken(user.getEmail());
+        user.setToken(token);
+
         return ResponseEntity.ok(user);
     }
@@ -38,6 +42,5 @@
         UserDto user = userService.register(signUpDto);
         user.setToken(userAuthProvider.createToken(user.getEmail()));
-        return ResponseEntity.created(URI.create("/users/" + user.getId()))
-                .body(user);
+        return ResponseEntity.created(URI.create("/users/" + user.getId())).body(user);
     }
 }
Index: src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java
===================================================================
--- src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java	(revision 5a9c93b9db42777251b6230e5814b5929eb94488)
+++ src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java	(revision 8ca35dc93473fb5be3777778a84fedee941c8790)
@@ -2,16 +2,25 @@
 
 import com.example.rezevirajmasa.demo.dto.CustomerDTO;
+import com.example.rezevirajmasa.demo.dto.UserDto;
+import com.example.rezevirajmasa.demo.mappers.UserMapper;
 import com.example.rezevirajmasa.demo.model.*;
-import com.example.rezevirajmasa.demo.service.CustomerService;
-import com.example.rezevirajmasa.demo.service.ReservationService;
-import com.example.rezevirajmasa.demo.service.RestaurantService;
-import com.example.rezevirajmasa.demo.service.TableService;
+import com.example.rezevirajmasa.demo.service.*;
+import com.example.rezevirajmasa.demo.service.impl.TokenService;
+import jakarta.servlet.http.HttpServletRequest;
 import jdk.jfr.consumer.RecordingStream;
 import org.apache.coyote.Response;
+import org.apache.http.protocol.HTTP;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.annotation.AuthenticationPrincipal;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.core.parameters.P;
+import org.springframework.security.core.userdetails.UserDetails;
 import org.springframework.web.bind.annotation.*;
 
+import java.nio.file.attribute.UserPrincipal;
+import java.security.Principal;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
@@ -26,12 +35,19 @@
     private final RestaurantService restaurantService;
     private final CustomerService customerService;
+    private final UserService userService;
     private final ReservationService reservationService;
+    private final ReservationHistoryService reservationHistoryService;
     private final TableService tableService;
-
-    public testController(RestaurantService restaurantService, CustomerService customerService, ReservationService reservationService, TableService tableService) {
+    private final UserMapper userMapper;
+    private final TokenService tokenService;
+    public testController(RestaurantService restaurantService, CustomerService customerService, UserService userService, ReservationService reservationService, ReservationHistoryService reservationHistoryService, TableService tableService, UserMapper userMapper, TokenService tokenService) {
         this.restaurantService = restaurantService;
         this.customerService = customerService;
+        this.userService = userService;
         this.reservationService = reservationService;
+        this.reservationHistoryService = reservationHistoryService;
         this.tableService = tableService;
+        this.userMapper = userMapper;
+        this.tokenService = tokenService;
     }
 
@@ -114,4 +130,16 @@
         );
     }
+    @GetMapping("/api/user")
+    public ResponseEntity<?> getCurrentUser() {
+        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+
+        if (authentication == null || !authentication.isAuthenticated() || authentication.getPrincipal().equals("anonymousUser")) {
+            return new ResponseEntity<>("User is not authenticated", HttpStatus.UNAUTHORIZED);
+        }
+
+        Customer customer = (Customer) authentication.getPrincipal();
+        return new ResponseEntity<>(customer, HttpStatus.OK);
+    }
+
 
     @PostMapping("/api/customers")
@@ -137,15 +165,18 @@
 //    Reservation Calls
 
-    @GetMapping("/api/reservations")
-    public ResponseEntity<List<Reservation>> getReservations() {
-        return new ResponseEntity<List<Reservation>>(reservationService.listAll(), HttpStatus.OK);
-    }
-
-    @PostMapping("/api/reservations")
-    public ResponseEntity<Reservation> createReservation(@RequestBody Reservation reservation) {
-        reservation.setReservationDateTime(LocalDateTime.now());
-        Reservation savedReservation = reservationService.makeReservationRest(reservation);
+    @GetMapping("/api/reservations/by/{email}")
+    public ResponseEntity<List<Reservation>> getReservations(@PathVariable String email) {
+        User user = userService.findByMail(email);
+        return new ResponseEntity<List<Reservation>>(reservationService.findReservationByUser(user), HttpStatus.OK);
+    }
+
+    @PostMapping("/api/reservations/{email}")
+    public ResponseEntity<Reservation> createReservation(@RequestBody Reservation reservation, @PathVariable String email) {
+        User user = userService.findByMail(email);
+        Reservation savedReservation = reservationService.makeReservationRest(reservation, user);
+
         return new ResponseEntity<>(savedReservation, HttpStatus.CREATED);
     }
+
 
     @GetMapping("/api/reservations/{reservationId}")
@@ -159,30 +190,38 @@
     }
 
-    @PostMapping("/api/reservations/{reservationId}")
+    @PostMapping("/api/reservations/{reservationId}/{email}")
     public ResponseEntity<Reservation> editReservation(@PathVariable Long reservationId,
-                                                       @RequestBody Reservation reservation) {
+                                                       @RequestBody Reservation reservation,
+                                                       @PathVariable String email) {
+        User user = userService.findByMail(email);
+
         if (!reservation.getReservationID().equals(reservationId)) {
             return ResponseEntity.badRequest().build();
         }
 
-        Reservation savedReservation = reservationService.findById(reservationId);
-        if(!reservation.getCheckInTime().equals(savedReservation.getCheckInTime())) {
-            tableService.canceledTimeSlots(savedReservation.getTable().getId(), savedReservation.getCheckInTime());
-        }
-
-        savedReservation.setReservationDateTime(LocalDateTime.now());
-        savedReservation.setCheckInTime(reservation.getCheckInTime());
-        savedReservation.setCheckOutTime(reservation.getCheckInTime().plusHours(2));
-        savedReservation.setPartySize(reservation.getPartySize());
-        savedReservation.setSpecialRequests(reservation.getSpecialRequests());
-        tableService.deleteTimeSlotsForReservation(reservation.getTable().getId(), reservation.getCheckInTime());
-
-        //moze da se vovede sistem za ako od 4ca doagjaat samo 2ca da se najde pomala masa po moznost ako ima u toj moment
-        //listaj samo slotovi za taa masa vo toj moment ili da ima da odbere od novo ama taka bolje nova rezevacij
-
-        Reservation updatedReservation = reservationService.makeReservationRest(savedReservation);
-        System.out.println("Saved reservation time: " + savedReservation.getCheckInTime());
+        // Fetch existing reservation
+        Reservation existingReservation = reservationService.findById(reservationId);
+        if (existingReservation == null) {
+            return ResponseEntity.notFound().build();
+        }
+
+        if (!reservation.getCheckInTime().equals(existingReservation.getCheckInTime())) {
+            tableService.canceledTimeSlots(existingReservation.getTable().getId(), existingReservation.getCheckInTime());
+
+            tableService.deleteTimeSlotsForReservation(reservation.getTable().getId(), reservation.getCheckInTime());
+        }
+
+        existingReservation.setReservationDateTime(LocalDateTime.now());
+        existingReservation.setCheckInTime(reservation.getCheckInTime());
+        existingReservation.setCheckOutTime(reservation.getCheckInTime().plusHours(2));
+        existingReservation.setPartySize(reservation.getPartySize());
+        existingReservation.setSpecialRequests(reservation.getSpecialRequests());
+
+        Reservation updatedReservation = reservationService.makeReservationRest(existingReservation, user);
+
+        System.out.println("Updated reservation time: " + updatedReservation.getCheckInTime());
         return ResponseEntity.ok(updatedReservation);
     }
+
 
     @DeleteMapping("/api/reservations/delete/{reservationId}")
@@ -196,4 +235,10 @@
     }
 
+    @GetMapping("/api/reservations/past/{email}")
+    public ResponseEntity<List<Restaurant.ReservationHistory>> pastReservations(@PathVariable String email) {
+        User user = userService.findByMail(email);
+        return null;
+    }
+
 //    TableEntity Calls
 
@@ -203,3 +248,11 @@
     }
 
+    // past reservation calls
+    @GetMapping("/api/past-reservations/{email}")
+    public ResponseEntity<List<Restaurant.ReservationHistory>> findPastReservationsByUser(@PathVariable String email) {
+        User user = userService.findByMail(email);
+        List<Restaurant.ReservationHistory> reservations = reservationHistoryService.findByUser(user);
+        return new ResponseEntity<>(reservations, HttpStatus.OK);
+    }
+
 }
