Commit fe7e995c by Bogdan Andjelkovic

if logged login register

parent 349ee492
...@@ -26,14 +26,18 @@ public class AppController ...@@ -26,14 +26,18 @@ public class AppController
} }
@GetMapping("/login") @GetMapping("/login")
public String getLogin( Model model ) public String getLogin( Model model, @AuthenticationPrincipal KorisnikDetails loggedUser)
{ {
if( loggedUser != null )
return "redirect:/index";
return("login"); return("login");
} }
@GetMapping("/register") @GetMapping("/register")
public String getRegister( Model model ) public String getRegister( Model model, @AuthenticationPrincipal KorisnikDetails loggedUser)
{ {
if( loggedUser != null )
return "redirect:/index";
model.addAttribute("newUser", new Korisnik()); model.addAttribute("newUser", new Korisnik());
return("register"); return("register");
} }
...@@ -45,6 +49,7 @@ public class AppController ...@@ -45,6 +49,7 @@ public class AppController
kRepo.insert( korisnik); kRepo.insert( korisnik);
return("redirect:/login"); return("redirect:/login");
} }
@GetMapping("/profile/{korisnikid}") @GetMapping("/profile/{korisnikid}")
public String getProfile(@PathVariable("korisnikid") int korisnikid, Model model, @AuthenticationPrincipal KorisnikDetails korisnik) public String getProfile(@PathVariable("korisnikid") int korisnikid, Model model, @AuthenticationPrincipal KorisnikDetails korisnik)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment