Commit c4f6c25c by Bogdan Andjelkovic

edit password - back finished

parent 147aaa1d
...@@ -75,7 +75,7 @@ public class ProfileController ...@@ -75,7 +75,7 @@ public class ProfileController
public String postPasswordEditSave(Model model, @ModelAttribute Korisnik korisnik, @AuthenticationPrincipal KorisnikDetails loggedUser) public String postPasswordEditSave(Model model, @ModelAttribute Korisnik korisnik, @AuthenticationPrincipal KorisnikDetails loggedUser)
{ {
System.out.println(korisnik.toString()); System.out.println(korisnik.toString());
kRepo.updateSifra( korisnik); kRepo.updateSifra( korisnik, loggedUser.getKorisnik().getKorisnikId());
loggedUser.setKorisnikSifra( korisnik.getSifra()); loggedUser.setKorisnikSifra( korisnik.getSifra());
return "redirect:/index"; return "redirect:/index";
} }
......
...@@ -153,11 +153,11 @@ public class KorisnikRepository ...@@ -153,11 +153,11 @@ public class KorisnikRepository
} }
} }
public void updateSifra( Korisnik korisnik) public void updateSifra( Korisnik korisnik, int korisnikId)
{ {
String sql = " update korisnik " + String sql = " update korisnik " +
" set sifra = '" + new BCryptPasswordEncoder().encode( korisnik.getSifra()) + " set sifra = '" + new BCryptPasswordEncoder().encode( korisnik.getSifra()) +
"' where korisnikid = " + korisnik.getKorisnikId(); "' where korisnikid = " + korisnikId;
try { try {
dataBase.statement.executeUpdate( sql); dataBase.statement.executeUpdate( sql);
} catch (SQLException e) { } catch (SQLException e) {
......
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