Ignore:
Timestamp:
02/06/23 17:05:56 (22 months ago)
Author:
milamihajlovska <mila.mihajlovska01@…>
Branches:
master
Children:
a69d48c
Parents:
43a1688
Message:

changes to register

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/moviezone/web/HomeController.java

    r43a1688 rf9cc555  
    44import com.example.moviezone.model.Customer;
    55import com.example.moviezone.model.Film;
     6import com.example.moviezone.model.Role;
    67import com.example.moviezone.model.User;
     8import com.example.moviezone.model.exceptions.PasswordsDoNotMatchException;
    79import com.example.moviezone.model.exceptions.UserNotFoundException;
    810import com.example.moviezone.service.*;
     
    9395    }
    9496
    95     @PostMapping("register")
    96     public String register(@RequestParam String username, @RequestParam String first_name, @RequestParam String last_name,
    97                          @RequestParam String password, @RequestParam String repeatedPassword,
    98                          @RequestParam String email, @RequestParam String number,
    99                          @RequestParam String role)
    100     {
    101         User user = null;
    102             user=userService.register(first_name,last_name,username,email,number,password,repeatedPassword,role);
     97    @PostMapping()
     98    public String register(@RequestParam String username,
     99                           @RequestParam String first_name,
     100                           @RequestParam String last_name,
     101                           @RequestParam String password,
     102                           @RequestParam String repeatedPassword,
     103                           @RequestParam String email,
     104                           @RequestParam String number,
     105                           @RequestParam Role role)
     106    {
     107        try {
     108           User user=userService.register(first_name,last_name,username,email,number,password,repeatedPassword,role);
    103109            return "redirect:/login";
     110        }catch (PasswordsDoNotMatchException exception)
     111        {
     112            return "redirect:/register?error=" + exception.getMessage();
     113        }
     114
    104115    }
    105116
Note: See TracChangeset for help on using the changeset viewer.