Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SkuciSe
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tim 2 - 2022
SkuciSe
Commits
d9d860dd
Commit
d9d860dd
authored
Sep 01, 2022
by
Bogdan Andjelkovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updateProfileBezSliek finished ( ostao front )
parent
09543786
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
19 deletions
+19
-19
SkuciSe/src/main/java/com/example/SkuciSe/controller/AppController.java
+4
-4
SkuciSe/src/main/java/com/example/SkuciSe/model/korisnik/KorisnikDetailsService.java
+0
-1
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
+8
-9
SkuciSe/src/main/resources/templates/profile.html
+7
-5
No files found.
SkuciSe/src/main/java/com/example/SkuciSe/controller/AppController.java
View file @
d9d860dd
...
...
@@ -58,15 +58,15 @@ public class AppController
public
String
getProfile
(
Model
model
,
@AuthenticationPrincipal
KorisnikDetails
loggedUser
)
{
model
.
addAttribute
(
"loggedUser"
,
loggedUser
);
model
.
addAttribute
(
"editUser"
,
loggedUser
);
model
.
addAttribute
(
"editUser"
,
loggedUser
.
getKorisnik
()
);
model
.
addAttribute
(
"profileRole"
,
kRepo
.
findRoleById
(
loggedUser
.
getKorisnik
().
getTipId
()));
return
(
"profile"
);
}
@PostMapping
(
"/profile-
edit
"
)
public
String
postProfileEdit
(
@ModelAttribute
Korisnik
Details
korisnikDetails
)
@PostMapping
(
"/profile-
update
"
)
public
String
postProfileEdit
(
@ModelAttribute
Korisnik
korisnik
)
{
kRepo
.
update
(
korisnik
Details
.
getKorisnik
()
);
kRepo
.
update
(
korisnik
);
return
"redirect:/profile"
;
}
}
SkuciSe/src/main/java/com/example/SkuciSe/model/korisnik/KorisnikDetailsService.java
View file @
d9d860dd
...
...
@@ -14,7 +14,6 @@ public class KorisnikDetailsService implements UserDetailsService
@Override
public
UserDetails
loadUserByUsername
(
String
email
)
throws
UsernameNotFoundException
{
Korisnik
korisnik
=
kRepo
.
findByEmail
(
email
);
System
.
out
.
println
(
korisnik
.
toString
());
if
(
korisnik
!=
null
)
{
return
new
KorisnikDetails
(
korisnik
);
...
...
SkuciSe/src/main/java/com/example/SkuciSe/repository/KorisnikRepository.java
View file @
d9d860dd
...
...
@@ -41,13 +41,13 @@ public class KorisnikRepository
public
void
update
(
Korisnik
korisnik
)
{
String
sql
=
"
insert into
korisnik "
+
"
where korisnikid = "
+
korisnik
.
getKorisnikId
()
+
"
set ime = "
+
korisnik
.
getI
me
()
+
"
,set prezime = "
+
korisnik
.
getPrezime
()
+
"
,set email = "
+
korisnik
.
getEmail
(
)
+
"
,set sifra = "
+
new
BCryptPasswordEncoder
().
encode
(
korisnik
.
getSifra
()
)
+
"
,set telefon = "
+
korisnik
.
getTelefon
();
String
sql
=
"
update
korisnik "
+
"
set ime = '"
+
korisnik
.
getIme
()
+
"
',prezime = '"
+
korisnik
.
getPrezi
me
()
+
"
',email = '"
+
korisnik
.
getEmail
()
+
"
',sifra = '"
+
new
BCryptPasswordEncoder
().
encode
(
korisnik
.
getSifra
()
)
+
"
',telefon = '"
+
korisnik
.
getTelefon
(
)
+
"
' where korisnikid = "
+
korisnik
.
getKorisnikId
();
try
{
System
.
out
.
println
(
sql
);
statement
.
executeUpdate
(
sql
);
...
...
@@ -64,8 +64,7 @@ public class KorisnikRepository
try
{
slika
=
Base64
.
getEncoder
().
encodeToString
(
file
.
getBytes
());
sql
=
" insert into korisnik "
+
" where korisnikid = "
+
korisnik
.
getKorisnikId
()
+
" set slika = "
+
slika
;
" set slika = '"
+
slika
+
"' where korisnikid = "
+
korisnik
.
getKorisnikId
();
System
.
out
.
println
(
sql
);
statement
.
executeUpdate
(
sql
);
}
catch
(
SQLException
e
)
{
...
...
SkuciSe/src/main/resources/templates/profile.html
View file @
d9d860dd
...
...
@@ -92,33 +92,35 @@
</div>
</div>
</div>
<form
class=
"requires-validation"
novalidate
th:object=
"${editUser}"
method=
"POST"
th:action=
"@{/profile-update}"
enctype=
"multipart/form-data"
>
<input
th:field=
"${editUser.korisnikId}"
class=
"form-control"
type=
"hidden"
name=
"name"
placeholder=
"Ime"
required
>
<div
class=
"col-md-12"
>
<input
th:field=
"${editUser.
getKorisnik().
ime}"
class=
"form-control"
type=
"text"
name=
"name"
placeholder=
"Ime"
required
>
<input
th:field=
"${editUser.ime}"
class=
"form-control"
type=
"text"
name=
"name"
placeholder=
"Ime"
required
>
<div
class=
"valid-feedback"
>
Dobro ime!
</div>
<div
class=
"invalid-feedback"
>
Ime ne sme biti prazno!
</div>
</div>
<div
class=
"col-md-12"
>
<input
th:field=
"${editUser.
getKorisnik().
prezime}"
class=
"form-control"
type=
"text"
name=
"surname"
placeholder=
"Prezime"
required
>
<input
th:field=
"${editUser.prezime}"
class=
"form-control"
type=
"text"
name=
"surname"
placeholder=
"Prezime"
required
>
<div
class=
"valid-feedback"
>
Dobro prezime!
</div>
<div
class=
"invalid-feedback"
>
Prezime ne sme biti prazno!
</div>
</div>
<div
class=
"col-md-12"
>
<input
th:field=
"${editUser.
getKorisnik().
telefon}"
class=
"form-control"
type=
"text"
name=
"phone"
placeholder=
"Broj telefona"
required
>
<input
th:field=
"${editUser.telefon}"
class=
"form-control"
type=
"text"
name=
"phone"
placeholder=
"Broj telefona"
required
>
<div
class=
"valid-feedback"
>
Dobar broj!
</div>
<div
class=
"invalid-feedback"
>
Broj telefona ne sme biti prazan!
</div>
</div>
<div
class=
"col-md-12"
>
<input
th:field=
"${editUser.
getKorisnik().
email}"
class=
"form-control"
type=
"email"
name=
"email"
placeholder=
"E-mail Adresa"
required
>
<input
th:field=
"${editUser.email}"
class=
"form-control"
type=
"email"
name=
"email"
placeholder=
"E-mail Adresa"
required
>
<div
class=
"valid-feedback"
>
Dobar email!
</div>
<div
class=
"invalid-feedback"
>
Email ne sme biti prazan!
</div>
</div>
<div
class=
"col-md-12"
>
<input
th:field=
"${editUser.
getKorisnik().
sifra}"
class=
"form-control"
type=
"password"
name=
"password"
placeholder=
"Sifra"
required
>
<input
th:field=
"${editUser.sifra}"
class=
"form-control"
type=
"password"
name=
"password"
placeholder=
"Sifra"
required
>
<div
class=
"valid-feedback"
>
Dobra sifra!
</div>
<div
class=
"invalid-feedback"
>
Sifra ne sme biti prazna!
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment