Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
th-app-java
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
1
Merge Requests
1
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
Oscar Enrique Gonzalez Escurra
th-app-java
Commits
f9730393
Commit
f9730393
authored
Nov 12, 2021
by
Cesar Giulano Gonzalez Maqueda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
editar datos de usuario
parent
9d28912b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
113 additions
and
10 deletions
+113
-10
curriculumsearch/src/main/java/com/roshka/configuration/CustomUserDetails.java
+5
-0
curriculumsearch/src/main/java/com/roshka/configuration/WebSecurityConfig.java
+1
-0
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
+2
-1
curriculumsearch/src/main/java/com/roshka/controller/RRHHUserController.java
+33
-9
curriculumsearch/src/main/webapp/jsp/edit-user-data.jsp
+65
-0
curriculumsearch/src/main/webapp/jsp/header.jsp
+4
-0
curriculumsearch/src/main/webapp/jsp/login.jsp
+3
-0
No files found.
curriculumsearch/src/main/java/com/roshka/configuration/CustomUserDetails.java
View file @
f9730393
...
@@ -53,4 +53,8 @@ public class CustomUserDetails implements UserDetails {
...
@@ -53,4 +53,8 @@ public class CustomUserDetails implements UserDetails {
return
user
.
getFirstName
()
+
" "
+
user
.
getLastName
();
return
user
.
getFirstName
()
+
" "
+
user
.
getLastName
();
}
}
@Override
public
String
toString
(){
return
user
.
getEmail
();
}
}
}
\ No newline at end of file
curriculumsearch/src/main/java/com/roshka/configuration/WebSecurityConfig.java
View file @
f9730393
...
@@ -55,6 +55,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
...
@@ -55,6 +55,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.
antMatchers
(
"/convocatoria*"
).
authenticated
()
.
antMatchers
(
"/convocatoria*"
).
authenticated
()
.
antMatchers
(
"/tecnologia*"
).
authenticated
()
.
antMatchers
(
"/tecnologia*"
).
authenticated
()
.
antMatchers
(
"/postulantes"
).
authenticated
()
.
antMatchers
(
"/postulantes"
).
authenticated
()
.
antMatchers
(
"/edit-user-data"
).
authenticated
()
.
anyRequest
().
permitAll
()
.
anyRequest
().
permitAll
()
.
and
()
.
and
()
.
formLogin
()
.
formLogin
()
...
...
curriculumsearch/src/main/java/com/roshka/controller/PostulanteController.java
View file @
f9730393
...
@@ -227,5 +227,5 @@ public class PostulanteController {
...
@@ -227,5 +227,5 @@ public class PostulanteController {
//post.save(postulanteVd);
//post.save(postulanteVd);
return
"redirect:/postulante/"
+
postulanteId
;
return
"redirect:/postulante/"
+
postulanteId
;
}
}
}
}
\ No newline at end of file
curriculumsearch/src/main/java/com/roshka/controller/RRHHUserController.java
View file @
f9730393
...
@@ -11,6 +11,9 @@ import org.springframework.http.HttpStatus;
...
@@ -11,6 +11,9 @@ import org.springframework.http.HttpStatus;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.context.SecurityContext
;
import
org.springframework.security.core.context.SecurityContextHolder
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
...
@@ -21,6 +24,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
...
@@ -21,6 +24,7 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.bind.annotation.ResponseStatus
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
org.springframework.web.servlet.mvc.support.RedirectAttributes
;
import
org.springframework.web.servlet.view.RedirectView
;
import
org.springframework.web.servlet.view.RedirectView
;
...
@@ -76,6 +80,35 @@ public class RRHHUserController {
...
@@ -76,6 +80,35 @@ public class RRHHUserController {
return
"register_success"
;
return
"register_success"
;
}
}
@GetMapping
(
"/edit-user-data"
)
public
String
editUserData
(
HttpServletRequest
request
,
Model
model
){
Authentication
auth
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
System
.
out
.
println
(
auth
.
getPrincipal
().
toString
());
System
.
out
.
println
(
rrhhUserRepository
.
findByEmail
(
auth
.
getPrincipal
().
toString
()));
model
.
addAttribute
(
"user"
,
rrhhUserRepository
.
findByEmail
(
auth
.
getPrincipal
().
toString
()));
return
"edit-user-data"
;
}
@PostMapping
(
"/edit-user-data"
)
public
RedirectView
processEditUser
(
HttpServletRequest
request
,
RRHHUser
user
,
RedirectAttributes
redirectAttributes
){
RRHHUser
editUser
=
rrhhUserRepository
.
findByEmail
(
SecurityContextHolder
.
getContext
().
getAuthentication
()
.
getPrincipal
().
toString
());
if
(
user
.
getEmail
()!=
null
){
editUser
.
setEmail
(
user
.
getEmail
());
}
if
(
user
.
getFirstName
()!=
null
){
editUser
.
setFirstName
(
user
.
getFirstName
());
}
if
(
user
.
getLastName
()!=
null
){
editUser
.
setLastName
(
user
.
getLastName
());
}
rrhhUserRepository
.
save
(
editUser
);
RedirectView
redirectView
=
new
RedirectView
(
"/home"
,
true
);
redirectAttributes
.
addFlashAttribute
(
"success"
,
"Datos actualizados"
);
return
redirectView
;
}
@Autowired
@Autowired
private
RRHHUserService
userService
;
private
RRHHUserService
userService
;
...
@@ -155,15 +188,6 @@ public class RRHHUserController {
...
@@ -155,15 +188,6 @@ public class RRHHUserController {
return
"redirect:/"
;
return
"redirect:/"
;
}
}
@ResponseStatus
(
HttpStatus
.
PERMANENT_REDIRECT
)
@ExceptionHandler
({
UsernameNotFoundException
.
class
})
public
RedirectView
handleValidationExceptions
(
RedirectAttributes
redir
,
UsernameNotFoundException
ex
)
{
RedirectView
redirectView
=
new
RedirectView
(
"/forgot-password"
,
true
);
redir
.
addAttribute
(
"error"
,
"Error al enviar el mail. Checkee sus credenciales"
+
" y intentelo de nuevo"
);
return
redirectView
;
}
}
}
class
Utility
{
class
Utility
{
...
...
curriculumsearch/src/main/webapp/jsp/edit-user-data.jsp
0 → 100644
View file @
f9730393
<
%@
taglib
prefix=
"form"
uri=
"http://www.springframework.org/tags/form"
%
>
<html>
<head>
<meta
charset=
"ISO-8859-1"
>
<title>
Edit Profile
</title>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin=
"anonymous"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin=
"anonymous"
></script>
</head>
<style>
@media
(
min-width
:
1025px
)
{
.h-custom
{
height
:
100vh
!important
;
}
}
</style>
<body>
<section
class=
"h-100 h-custom"
>
<div
class=
"container py-5 h-100"
>
<div
class=
"row d-flex justify-content-center align-items-center h-100"
>
<div
class=
"col-lg-8 col-xl-6"
>
<div
class=
"card rounded-3"
>
<img
src=
"https://cdn.pixabay.com/photo/2013/08/09/05/54/layer-170971_960_720.jpg"
class=
"w-100"
style=
"border-top-left-radius: .3rem; border-top-right-radius: .3rem;height: 250px;"
alt=
"Sample photo"
;
>
<div
class=
"card-body p-4 p-md-5"
>
<h3
class=
"mb-4 pb-2 pb-md-0 mb-md-5 px-md-2"
>
Perfil
</h3>
<form:form
action=
"/edit-user-data"
class=
"px-md-2"
method=
"POST"
modelAttribute=
"user"
>
<div
class=
"form-outline mb-4"
>
<form:label
path=
"email"
class=
"form-label"
>
Email
</form:label>
<form:input
path=
"email"
type=
"email"
class=
"form-control"
required=
"required"
></form:input>
</div>
<div
class=
"row"
>
<div
class=
"col-md-6 mb-4"
>
<div
class=
"form-outline"
>
<form:label
path=
"firstName"
class=
"form-label"
>
Nombre
</form:label>
<form:input
path=
"firstName"
class=
"form-control"
></form:input>
</div>
</div>
<div
class=
"col-md-6 mb-4"
>
<div
class=
"form-outline"
>
<form:label
path=
"lastName"
class=
"form-label"
>
Apellido
</form:label>
<form:input
path=
"lastName"
class=
"form-control"
></form:input>
</div>
</div>
</div>
<div
class=
"row mb-4 pb-2 pb-md-0 mb-md-5"
>
<div
class=
"col-md-6"
>
</div>
</div>
<button
type=
"submit"
class=
"btn btn-success btn-lg mb-1"
>
Submit
</button>
</form:form>
</div>
</div>
</div>
</div>
</div>
</section>
</body>
</html>
curriculumsearch/src/main/webapp/jsp/header.jsp
View file @
f9730393
...
@@ -46,8 +46,12 @@
...
@@ -46,8 +46,12 @@
</ul>
</ul>
</li>
</li>
<li class="nav-item">
<li class="nav-item">
<a class="nav-link" href="/edit-user-data">Editar mis datos</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/logout">Salir</a>
<a class="nav-link" href="/logout">Salir</a>
</li>
</li>
</ul>
</ul>
</div>
</div>
</div>
</div>
...
...
curriculumsearch/src/main/webapp/jsp/login.jsp
View file @
f9730393
...
@@ -41,6 +41,9 @@
...
@@ -41,6 +41,9 @@
<div
class=
"row"
>
<div
class=
"row"
>
<a
href=
"/forgot-password"
>
Olvidaste tu contrasena?
</a>
<a
href=
"/forgot-password"
>
Olvidaste tu contrasena?
</a>
</div>
</div>
<div
class=
"row"
>
<a
href=
"/register"
>
Registrate
</a>
</div>
</div>
</div>
</div>
</div>
</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