Changeset f25e8dd in Git for src/main/java/com


Ignore:
Timestamp:
02/05/22 22:48:19 (3 years ago)
Author:
Petar Partaloski <ppartaloski@…>
Branches:
main
Children:
2efe93e
Parents:
5b447b0
Message:

Fixed and added a better front end, improved clarity

Location:
src/main/java/com/wediscussmovies/project
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/wediscussmovies/project/configuration/SecurityConfig.java

    r5b447b0 rf25e8dd  
    55import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
    66import org.springframework.security.config.annotation.web.builders.HttpSecurity;
     7import org.springframework.security.config.annotation.web.builders.WebSecurity;
    78import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
    89
     
    1516    }
    1617
     18    @Override
     19    public void configure(WebSecurity web) throws Exception {
     20        web.ignoring().antMatchers("/*.jpg");
     21        web.ignoring().antMatchers("/*.png");
     22        web.ignoring().antMatchers("/*.css");
     23        web.ignoring().antMatchers("/*.js");
     24    }
    1725
    1826    @Override
     
    2129        http.csrf().disable()
    2230                .authorizeRequests()
    23                 .antMatchers("/movies","/actors","/directors","/discussions","/replies","/register","/genres").permitAll()
     31                .antMatchers("/movies","/movies/**/","/actors","/persons/**/","/directors","/discussions","/discussions/**/","/discussions/all/**/","/replies","/register","/genres").permitAll()
    2432                .anyRequest()
    2533                .authenticated()
  • src/main/java/com/wediscussmovies/project/model/Movie.java

    r5b447b0 rf25e8dd  
    66import com.wediscussmovies.project.model.relation.MovieRates;
    77import lombok.Data;
     8import org.hibernate.annotations.Fetch;
    89
    910import javax.persistence.*;
     
    3738    private Double imdbRating;
    3839
    39     @OneToMany(mappedBy = "movie")
     40    @OneToMany(mappedBy = "movie", fetch = FetchType.LAZY)
    4041    private Collection<MovieActors> actors;
    4142    @OneToMany(mappedBy = "movie")
  • src/main/java/com/wediscussmovies/project/web/controller/MovieController.java

    r5b447b0 rf25e8dd  
    6161    }
    6262
     63    @GetMapping("/{id}")
     64    public String getMovie(@PathVariable Integer id, Model model){
     65        model.addAttribute("movie", movieService.findById(id));
     66
     67        Authentication auth = SecurityContextHolder.getContext().getAuthentication();
     68        if (!(auth instanceof AnonymousAuthenticationToken)){
     69            UserDetails userDetails = (UserDetails) auth.getPrincipal();
     70            User user = (User) userDetails;
     71            model.addAttribute("likedMovies",this.movieService.findLikedMoviesByUser(user));
     72            model.addAttribute("user",user);
     73        }
     74
     75        model.addAttribute("contentTemplate", "movieShow");
     76        return "template";
     77    }
    6378
    6479    @GetMapping("/add")
  • src/main/java/com/wediscussmovies/project/web/controller/PersonController.java

    r5b447b0 rf25e8dd  
    4545        model.addAttribute("persons", persons);
    4646        model.addAttribute("contentTemplate", "personsList");
     47        return "template";
     48    }
     49
     50    @GetMapping("/persons/{id}")
     51    public String getPerson(@PathVariable Integer id, Model model){
     52        Person person = personService.findById(id);
     53        //Error handling, could be null!!!!!!!!!
     54        model.addAttribute("person", person);
     55
     56        model.addAttribute("contentTemplate", "personShow");
    4757        return "template";
    4858    }
Note: See TracChangeset for help on using the changeset viewer.