Index: trip-planner/src/main/java/finki/diplomska/tripplanner/TripPlannerApplication.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/TripPlannerApplication.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/TripPlannerApplication.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -6,4 +6,9 @@
 import org.springframework.context.annotation.Bean;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.CorsConfigurationSource;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+
+import java.util.Arrays;
 
 @SpringBootApplication
@@ -15,4 +20,6 @@
         return new BCryptPasswordEncoder();
     }
+
+
     public static void main(String[] args) {
         SpringApplication.run(TripPlannerApplication.class, args);
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/models/Planner.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/models/Planner.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/models/Planner.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -1,6 +1,6 @@
 package finki.diplomska.tripplanner.models;
 
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import lombok.*;
-import reactor.util.annotation.Nullable;
 
 import javax.persistence.*;
@@ -10,5 +10,4 @@
 @Data
 @Table(name = "planners")
-@NoArgsConstructor
 @AllArgsConstructor
 @Getter
@@ -34,9 +33,15 @@
     private List<Location> locationList;
 
+    @ManyToOne(fetch = FetchType.EAGER)
+    private User user;
 
-    public Planner(String name, String description, List<Location> locationList){
+    public Planner(){
+    }
+
+    public Planner(String name, String description, List<Location> locationList, User user){
             this.name = name;
             this.description = description;
             this.locationList = locationList;
+            this.user = user;
     }
 
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/models/User.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/models/User.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/models/User.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -11,6 +11,8 @@
 import javax.validation.constraints.Email;
 import javax.validation.constraints.NotBlank;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
+import java.util.List;
 
 @Entity
@@ -38,9 +40,18 @@
     private Date update_At;
 
-    //OneToMany with Project
+    //OneToMany with Planners
+    @OneToMany(cascade = CascadeType.REFRESH, fetch = FetchType.EAGER, mappedBy = "user", orphanRemoval = true)
+    @JsonIgnore
+    private List<Planner> planners = new ArrayList<>();
 
     public User() {
     }
 
+    public User(String username, String fullName, String password, String confirmPassword) {
+        this.username = username;
+        this.fullName = fullName;
+        this.password = password;
+        this.confirmPassword = confirmPassword;
+    }
 
     @PrePersist
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/models/dto/PlannerDto.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/models/dto/PlannerDto.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/models/dto/PlannerDto.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -9,8 +9,10 @@
     private String name;
     private String description;
+    private String user;
 
-    public PlannerDto(String name, String description) {
+    public PlannerDto(String name, String description, String user) {
         this.name = name;
         this.description = description;
+        this.user = user;
     }
 }
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/models/dto/UserDto.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/models/dto/UserDto.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/models/dto/UserDto.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -20,11 +20,10 @@
     private Date update_At;
 
-    public UserDto(String username, String fullName, String password, String confirmPassword, Date create_At, Date update_At) {
+    public UserDto(String username, String fullName, String password, String confirmPassword) {
         this.username = username;
         this.fullName = fullName;
         this.password = password;
         this.confirmPassword = confirmPassword;
-        this.create_At = create_At;
-        this.update_At = update_At;
+
     }
 }
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/payload/JWTLoginSucessReponse.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/payload/JWTLoginSucessReponse.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/payload/JWTLoginSucessReponse.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -0,0 +1,36 @@
+package finki.diplomska.tripplanner.payload;
+
+public class JWTLoginSucessReponse {
+
+    private boolean success;
+    private String token;
+
+    public JWTLoginSucessReponse(boolean success, String token) {
+        this.success = success;
+        this.token = token;
+    }
+
+    public boolean isSuccess() {
+        return success;
+    }
+
+    public void setSuccess(boolean success) {
+        this.success = success;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    @Override
+    public String toString() {
+        return "JWTLoginSucessReponse{" +
+                "success=" + success +
+                ", token='" + token + '\'' +
+                '}';
+    }
+}
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/payload/LoginRequest.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/payload/LoginRequest.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/payload/LoginRequest.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -0,0 +1,28 @@
+package finki.diplomska.tripplanner.payload;
+
+import javax.validation.constraints.NotBlank;
+
+public class LoginRequest {
+
+    @NotBlank(message = "Username cannot be blank")
+    private String username;
+
+    @NotBlank(message = "Password cannot be blank")
+    private String password;
+
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+}
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaPlannerRepository.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaPlannerRepository.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaPlannerRepository.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -4,4 +4,6 @@
 import finki.diplomska.tripplanner.models.Planner;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
 
@@ -11,4 +13,5 @@
 public interface JpaPlannerRepository extends JpaRepository<Planner, Long> {
 
-
+        @Query(value = "SELECT * FROM planners AS p left JOIN users AS u ON p.user_id = u.id WHERE u.username like :username", nativeQuery = true)
+        List<Planner> getPlannersByUser(@Param("username") String username );
 }
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaUserRepository.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaUserRepository.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/repository/jpa/JpaUserRepository.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -7,3 +7,5 @@
 @Repository
 public interface JpaUserRepository extends CrudRepository<User, Long> {
+    User findByUsername(String username);
+    User getById(Long id);
 }
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/security/JwtAuthenticationFilter.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/security/JwtAuthenticationFilter.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/security/JwtAuthenticationFilter.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -0,0 +1,66 @@
+package finki.diplomska.tripplanner.security;
+
+import finki.diplomska.tripplanner.models.User;
+import finki.diplomska.tripplanner.service.impl.CustomUserDetailsServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
+import org.springframework.util.StringUtils;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.Collections;
+
+public class JwtAuthenticationFilter extends OncePerRequestFilter {
+    @Autowired
+    private JwtTokenProvider tokenProvider;
+
+    @Autowired
+    private CustomUserDetailsServiceImpl customUserDetailsService;
+
+    @Override
+    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse,
+                                    FilterChain filterChain) throws ServletException, IOException {
+
+        try {
+
+            String jwt = getJWTFromRequest(httpServletRequest);
+
+            if(StringUtils.hasText(jwt)&& tokenProvider.validateToken(jwt)){
+                Long userId = tokenProvider.getUserIdFromJWT(jwt);
+                User userDetails = customUserDetailsService.loadUserById(userId);
+
+                UsernamePasswordAuthenticationToken authentication = new UsernamePasswordAuthenticationToken(
+                        userDetails, null, Collections.emptyList());
+
+                authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(httpServletRequest));
+                SecurityContextHolder.getContext().setAuthentication(authentication);
+
+            }
+
+        }catch (Exception ex){
+            logger.error("Could not set user authentication in security context", ex);
+        }
+
+
+        filterChain.doFilter(httpServletRequest, httpServletResponse);
+
+    }
+
+
+
+    private String getJWTFromRequest(HttpServletRequest request){
+        String bearerToken = request.getHeader(SecurityConstants.HEADER_STRING);
+
+        if(StringUtils.hasText(bearerToken)&&bearerToken.startsWith(SecurityConstants.TOKEN_PREFIX)){
+            return bearerToken.substring(7, bearerToken.length());
+        }
+
+        return null;
+    }
+}
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/security/JwtTokenProvider.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/security/JwtTokenProvider.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/security/JwtTokenProvider.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -0,0 +1,63 @@
+package finki.diplomska.tripplanner.security;
+
+import finki.diplomska.tripplanner.models.User;
+import io.jsonwebtoken.*;
+import org.springframework.security.core.Authentication;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+@Component
+public class JwtTokenProvider {
+    //Generate the token
+
+    public String generateToken(Authentication authentication){
+        User user = (User)authentication.getPrincipal();
+        Date now = new Date(System.currentTimeMillis());
+
+        Date expiryDate = new Date(now.getTime()+SecurityConstants.EXPIRATION_TIME);
+
+        String userId = Long.toString(user.getId());
+
+        Map<String,Object> claims = new HashMap<>();
+        claims.put("id", (Long.toString(user.getId())));
+        claims.put("username", user.getUsername());
+        claims.put("fullName", user.getFullName());
+
+        return Jwts.builder()
+                .setSubject(userId)
+                .setClaims(claims)
+                .setIssuedAt(now)
+                .setExpiration(expiryDate)
+                .signWith(SignatureAlgorithm.HS512, SecurityConstants.SECRET)
+                .compact();
+    }
+
+    //Validate the token
+    public boolean validateToken(String token){
+        try{
+            Jwts.parser().setSigningKey(SecurityConstants.SECRET).parseClaimsJws(token);
+            return true;
+        }catch (SignatureException ex){
+            System.out.println("Invalid JWT Signature");
+        }catch (MalformedJwtException ex){
+            System.out.println("Invalid JWT Token");
+        }catch (ExpiredJwtException ex){
+            System.out.println("Expired JWT token");
+        }catch (UnsupportedJwtException ex){
+            System.out.println("Unsupported JWT token");
+        }catch (IllegalArgumentException ex){
+            System.out.println("JWT claims string is empty");
+        }
+        return false;
+    }
+    //Get user Id from token
+    public Long getUserIdFromJWT(String token){
+        Claims claims = Jwts.parser().setSigningKey(SecurityConstants.SECRET).parseClaimsJws(token).getBody();
+        String id = (String)claims.get("id");
+
+        return Long.parseLong(id);
+    }
+}
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConfig.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConfig.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConfig.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -2,6 +2,11 @@
 
 
+import finki.diplomska.tripplanner.service.impl.CustomUserDetailsServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.BeanIds;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
 import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@@ -9,4 +14,9 @@
 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
 import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+import static finki.diplomska.tripplanner.security.SecurityConstants.MARIADB_URL;
+import static finki.diplomska.tripplanner.security.SecurityConstants.SIGN_UP_URLS;
 
 @Configuration
@@ -21,4 +31,25 @@
     @Autowired
     private JwtAuthenticationEntryPoint unauthorizedHandler;
+
+    @Autowired
+    private CustomUserDetailsServiceImpl customUserDetailsService;
+
+    @Bean
+    public JwtAuthenticationFilter jwtAuthenticationFilter() {return  new JwtAuthenticationFilter();}
+
+
+    @Autowired
+    private BCryptPasswordEncoder bCryptPasswordEncoder;
+
+    @Override
+    protected void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
+        authenticationManagerBuilder.userDetailsService(customUserDetailsService).passwordEncoder(bCryptPasswordEncoder);
+    }
+
+    @Override
+    @Bean(BeanIds.AUTHENTICATION_MANAGER)
+    protected AuthenticationManager authenticationManager() throws Exception {
+        return super.authenticationManager();
+    }
 
     @Override
@@ -43,6 +74,9 @@
                         "/**/*.js"
                 ).permitAll()
-                .antMatchers("/api/users/**").permitAll()
+                .antMatchers(SIGN_UP_URLS).permitAll()
+                .antMatchers(MARIADB_URL).permitAll()
                 .anyRequest().authenticated();
+        http.addFilterBefore(jwtAuthenticationFilter(), UsernamePasswordAuthenticationFilter.class);
+
     }
 }
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConstants.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConstants.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/security/SecurityConstants.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -0,0 +1,10 @@
+package finki.diplomska.tripplanner.security;
+
+public class SecurityConstants {
+    public static final String SIGN_UP_URLS = "/api/users/**";
+    public static final String MARIADB_URL = "jdbc:mariadb://127.0.0.1:3306/tripplanner";
+    public static final String SECRET ="SecretKeyToGenJWTs";
+    public static final String TOKEN_PREFIX= "Bearer ";
+    public static final String HEADER_STRING = "Authorization";
+    public static final long EXPIRATION_TIME = 3000_000; //30 seconds
+}
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/service/PlannerService.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/service/PlannerService.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/service/PlannerService.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -11,8 +11,9 @@
 
         Planner createPlannerWithRequestParams(String description, String name, List<Location> locationList);
-        Optional<Planner> editPlanner(Long id, PlannerDto plannerDto);
+        Optional<Planner> editPlanner(Long id, PlannerDto plannerDto, String username);
         List<Planner> getAllPlaners();
+        List<Planner> getPlannersByUser(String username);
         Optional<Planner> findById(Long id);
         Planner editPlannerWithRequestParams(Long id, String description, String name, List<Location> locationList);
-        Optional<Planner> newPlanner(PlannerDto plannerDto);
+        Optional<Planner> newPlanner(PlannerDto plannerDto, String username);
 }
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/service/UserService.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/service/UserService.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/service/UserService.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -2,5 +2,7 @@
 
 import finki.diplomska.tripplanner.models.User;
+import finki.diplomska.tripplanner.models.dto.UserDto;
 
+import java.util.Optional;
 
 
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/CustomUserDetailsServiceImpl.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/CustomUserDetailsServiceImpl.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/CustomUserDetailsServiceImpl.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -0,0 +1,34 @@
+package finki.diplomska.tripplanner.service.impl;
+
+import finki.diplomska.tripplanner.models.User;
+import finki.diplomska.tripplanner.repository.jpa.JpaUserRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.core.userdetails.UserDetailsService;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+
+import javax.transaction.Transactional;
+
+@Service
+public class CustomUserDetailsServiceImpl implements UserDetailsService {
+
+    @Autowired
+    private JpaUserRepository userRepository;
+
+    @Override
+    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
+        User user = userRepository.findByUsername(username);
+        if(user==null) new UsernameNotFoundException("User not found");
+        return user;
+    }
+
+
+    @Transactional
+    public User loadUserById(Long id){
+        User user = userRepository.getById(id);
+        if(user==null) new UsernameNotFoundException("User not found");
+        return user;
+
+    }
+}
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/PlannerServiceImpl.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/PlannerServiceImpl.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/PlannerServiceImpl.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -3,4 +3,5 @@
 import finki.diplomska.tripplanner.models.Location;
 import finki.diplomska.tripplanner.models.Planner;
+import finki.diplomska.tripplanner.models.User;
 import finki.diplomska.tripplanner.models.dto.PlannerDto;
 import finki.diplomska.tripplanner.models.exceptions.LocationNotFoundException;
@@ -8,10 +9,9 @@
 import finki.diplomska.tripplanner.repository.jpa.JpaLocationRepository;
 import finki.diplomska.tripplanner.repository.jpa.JpaPlannerRepository;
-import finki.diplomska.tripplanner.service.LocationService;
+import finki.diplomska.tripplanner.repository.jpa.JpaUserRepository;
 import finki.diplomska.tripplanner.service.PlannerService;
 import org.springframework.stereotype.Service;
-import reactor.util.annotation.Nullable;
 
-import java.util.ArrayList;
+import javax.jws.soap.SOAPBinding;
 import java.util.List;
 import java.util.Optional;
@@ -22,8 +22,10 @@
     private final JpaPlannerRepository plannerRepository;
     private final JpaLocationRepository locationRepository;
+    private final JpaUserRepository userRepository;
 
-    public PlannerServiceImpl(JpaPlannerRepository plannerRepository, JpaLocationRepository locationRepository) {
+    public PlannerServiceImpl(JpaPlannerRepository plannerRepository, JpaLocationRepository locationRepository, JpaUserRepository userRepository) {
         this.plannerRepository = plannerRepository;
         this.locationRepository = locationRepository;
+        this.userRepository = userRepository;
     }
 
@@ -31,4 +33,10 @@
     public List<Planner> getAllPlaners() {
         return this.plannerRepository.findAll();
+    }
+
+    @Override
+    public List<Planner> getPlannersByUser(String username) {
+        User user = this.userRepository.findByUsername(username);
+        return this.plannerRepository.getPlannersByUser(user.getUsername());
     }
 
@@ -40,5 +48,5 @@
 
     @Override
-    public Optional<Planner> newPlanner(PlannerDto plannerDto) {
+    public Optional<Planner> newPlanner(PlannerDto plannerDto, String username) {
         /*
         List<Location> locationList  = new ArrayList<>();
@@ -48,7 +56,8 @@
             locationList.add(loc);
         }
-
          */
-           return Optional.of(this.plannerRepository.save(new Planner(plannerDto.getName(), plannerDto.getDescription(), null)));
+        User user = this.userRepository.findByUsername(username);
+        plannerDto.setUser(user.getUsername());
+        return Optional.of(this.plannerRepository.save(new Planner(plannerDto.getName(), plannerDto.getDescription(), null, user)));
     }
 
@@ -69,9 +78,12 @@
 
     @Override
-    public Optional<Planner> editPlanner(Long id, PlannerDto plannerDto) {
+    public Optional<Planner> editPlanner(Long id, PlannerDto plannerDto, String username) {
         Planner planner = this.plannerRepository.findById(id).orElseThrow(() -> new PlannerNotFoundException(id));
+        User user = this.userRepository.findByUsername(username);
 
         planner.setName(plannerDto.getName());
         planner.setDescription(plannerDto.getDescription());
+        plannerDto.setUser(user.getUsername());
+        planner.setUser(user);
 /*
         List<Location> locationList  = new ArrayList<>();
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/UserServiceImpl.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/UserServiceImpl.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/service/impl/UserServiceImpl.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -9,4 +9,6 @@
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.stereotype.Service;
+
+import java.util.Optional;
 
 
@@ -28,5 +30,5 @@
             // We don't persist or show the confirmPassword
             newUser.setConfirmPassword("");
-            return this.userRepository.save(newUser);
+             return this.userRepository.save(newUser);
         }catch(Exception e){
             throw new UsernameAlreadyExistsException("Username '"+newUser.getUsername()+ "' already exists");
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/PlannerRestController.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/PlannerRestController.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/PlannerRestController.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -3,4 +3,5 @@
 import finki.diplomska.tripplanner.models.Location;
 import finki.diplomska.tripplanner.models.Planner;
+import finki.diplomska.tripplanner.models.User;
 import finki.diplomska.tripplanner.models.dto.PlannerDto;
 import finki.diplomska.tripplanner.service.LocationService;
@@ -9,7 +10,9 @@
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
+import org.springframework.security.core.Authentication;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
 import java.util.ArrayList;
 import java.util.List;
@@ -17,5 +20,5 @@
 
 @RestController
-@CrossOrigin(origins = "http://localhost:4200")
+@CrossOrigin(origins = "http://localhost:4200",  exposedHeaders = "token")
 @RequestMapping(value = "/api")
 public class PlannerRestController {
@@ -31,4 +34,11 @@
     public List<Planner> getAllPlanners(){
         return this.plannerService.getAllPlaners();
+    }
+
+
+    @GetMapping(value = "/planners/user")
+    public List<Planner> getPlannersByUser(Authentication authentication){
+        User user = (User) authentication.getPrincipal();
+        return this.plannerService.getPlannersByUser(user.getUsername());
     }
 
@@ -57,6 +67,8 @@
     @PostMapping(value = "/planner/new", consumes= MediaType.APPLICATION_JSON_VALUE)
     @ResponseStatus(HttpStatus.CREATED)
-    public ResponseEntity<Planner> newPlanner(@RequestBody PlannerDto plannerDto)  {
-        return this.plannerService.newPlanner(plannerDto)
+    public ResponseEntity<?> newPlanner(@Valid @RequestBody PlannerDto plannerDto, Authentication authentication)  {
+
+        User user = (User) authentication.getPrincipal();
+        return this.plannerService.newPlanner(plannerDto, user.getUsername())
                 .map(planner -> ResponseEntity.ok().body(planner))
                 .orElseGet(() -> ResponseEntity.badRequest().build());
@@ -65,6 +77,7 @@
 
     @PutMapping(value ="edit/planner/{id}", consumes= MediaType.APPLICATION_JSON_VALUE)
-    public ResponseEntity<Planner> editPlanner(@PathVariable Long id, @RequestBody PlannerDto plannerDto){
-        return this.plannerService.editPlanner(id, plannerDto)
+    public ResponseEntity<Planner> editPlanner(@PathVariable Long id, @Valid @RequestBody PlannerDto plannerDto, Authentication authentication){
+        User user = (User) authentication.getPrincipal();
+        return this.plannerService.editPlanner(id, plannerDto, user.getUsername())
                 .map(planner -> ResponseEntity.ok().body(planner))
                 .orElseGet(()-> ResponseEntity.badRequest().build());
Index: trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/UserController.java
===================================================================
--- trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/UserController.java	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/java/finki/diplomska/tripplanner/web/rest/UserController.java	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -3,4 +3,8 @@
 import finki.diplomska.tripplanner.models.User;
 import finki.diplomska.tripplanner.models.dto.UserDto;
+import finki.diplomska.tripplanner.payload.JWTLoginSucessReponse;
+import finki.diplomska.tripplanner.payload.LoginRequest;
+import finki.diplomska.tripplanner.security.JwtTokenProvider;
+import finki.diplomska.tripplanner.security.SecurityConstants;
 import finki.diplomska.tripplanner.service.UserService;
 import finki.diplomska.tripplanner.service.impl.MapValidationErrorService;
@@ -9,7 +13,10 @@
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
-
+import org.springframework.security.core.Authentication;
 import javax.validation.Valid;
 
@@ -28,5 +35,29 @@
     private UserValidator userValidator;
 
-    @PostMapping("/register")
+    @Autowired
+    private JwtTokenProvider tokenProvider;
+
+    @Autowired
+    private AuthenticationManager authenticationManager;
+
+    @PostMapping(value = "/login")
+    public ResponseEntity<?> authenticateUser(@Valid @RequestBody LoginRequest loginRequest, BindingResult result){
+        ResponseEntity<?> errorMap = mapValidationErrorService.MapValidationService(result);
+        if(errorMap != null) return errorMap;
+
+        Authentication authentication = authenticationManager.authenticate(
+                new UsernamePasswordAuthenticationToken(
+                        loginRequest.getUsername(),
+                        loginRequest.getPassword()
+                )
+        );
+
+        SecurityContextHolder.getContext().setAuthentication(authentication);
+        String jwt = SecurityConstants.TOKEN_PREFIX +  tokenProvider.generateToken(authentication);
+
+        return ResponseEntity.ok(new JWTLoginSucessReponse(true, jwt));
+    }
+
+    @PostMapping(value = "/register")
     public ResponseEntity<?> registerUser(@Valid @RequestBody User user, BindingResult result){
         // Validate passwords match
@@ -38,4 +69,5 @@
 
         return  new ResponseEntity<User>(newUser, HttpStatus.CREATED);
+
     }
 }
Index: trip-planner/src/main/resources/application.properties
===================================================================
--- trip-planner/src/main/resources/application.properties	(revision 1ad8e64a349fcc7c996155279b16efc2cfe001dd)
+++ trip-planner/src/main/resources/application.properties	(revision 84d0fbb56bfbe319ba63e3327f1777ac5d841f83)
@@ -6,4 +6,5 @@
 jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
 jasypt.encryptor.algorithm=PBEWithMD5AndDES
+spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
 
 spring.jpa.show-sql=true
