Changeset 7926d68 for src


Ignore:
Timestamp:
02/10/23 01:52:11 (21 months ago)
Author:
DenicaKj <dkorvezir@…>
Branches:
master
Children:
ef84238
Parents:
73f0dbc
Message:

Profiles for user and worker

Location:
src/main
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/config/WebSecurityConfig.java

    r73f0dbc r7926d68  
    3333                .authorizeRequests()
    3434                .antMatchers("/","/films","/home/projections","/home/events","/home/getProjections/**","/home/films","/home/getFilm/**","/getFilm/**","/home/getEvent/**","/getEvent/**","/login","/events","/projections" ,"/home", "/assets/**", "/register", "/api/**").permitAll()
    35                 .antMatchers("/home/getSeats/**","/myTickets","/home/addRating/**","/addRating/**","/getProjection/**","/home/makeReservation").hasRole("USER")
     35                .antMatchers("/home/getSeats/**","/myTickets","/home/addRating/**","/addRating/**","/getProjection/**","/home/makeReservation","/profileUser").hasRole("USER")
    3636                .antMatchers("/**").hasRole("ADMIN")
    3737                .anyRequest()
  • src/main/java/com/example/moviezone/repository/WorkerRepository.java

    r73f0dbc r7926d68  
    77@Repository
    88public interface WorkerRepository extends JpaRepository<Worker,Integer> {
     9    Worker getByUsername(String username);
    910}
  • src/main/java/com/example/moviezone/service/Impl/WorkerServiceImpl.java

    r73f0dbc r7926d68  
    2020        return workerRepository.findAll();
    2121    }
     22
     23    @Override
     24    public Worker getWorkerByUsername(String username) {
     25        return workerRepository.getByUsername(username);
     26    }
    2227}
  • src/main/java/com/example/moviezone/service/WorkerService.java

    r73f0dbc r7926d68  
    77public interface WorkerService {
    88    List<Worker> findAllWorkers();
     9    Worker getWorkerByUsername(String username);
    910}
  • src/main/java/com/example/moviezone/web/HomeController.java

    r73f0dbc r7926d68  
    403403        return "redirect:/home/getFilm/"+id;
    404404    }
    405 
     405    @GetMapping("/profileWorker")
     406    public String getWorkerProfile(Model model,HttpServletRequest request)
     407    {
     408        Worker worker=workerService.getWorkerByUsername(request.getRemoteUser());
     409        model.addAttribute("worker",worker);
     410        model.addAttribute("bodyContent", "profileWorker");
     411        return "master-template";
     412    }
     413    @GetMapping("/profileUser")
     414    public String getUserProfile(Model model,HttpServletRequest request)
     415    {
     416        Customer customer=customerService.findByUsername(request.getRemoteUser());
     417        System.out.println(customer.getFirst_name());
     418        model.addAttribute("customer",customer);
     419        model.addAttribute("bodyContent", "profileUser");
     420        return "master-template";
     421    }
    406422}
  • src/main/resources/templates/fragments/header.html

    r73f0dbc r7926d68  
    8383    </ul>
    8484    <ul class="menu-right">
    85         <th:block th:if="${#request.getRemoteUser() != null}">
     85        <th:block sec:authorize="hasAuthority('ROLE_ADMIN')" th:if="${#request.getRemoteUser() != null}">
    8686            <li class="reg">
    87                 <a href="/">
     87                <a href="/profileWorker">
     88                    <th:block th:text="${#request.getRemoteUser()}"></th:block>
     89                </a>
     90            </li>
     91        </th:block>
     92        <th:block sec:authorize="hasAuthority('ROLE_USER')" th:if="${#request.getRemoteUser() != null}">
     93            <li class="reg">
     94                <a href="/profileUser">
    8895                    <th:block th:text="${#request.getRemoteUser()}"></th:block>
    8996                </a>
Note: See TracChangeset for help on using the changeset viewer.