diff --git a/.idea/WPD-Auth.iml b/.idea/WPD-Auth.iml
new file mode 100644
index 0000000..18ec59d
--- /dev/null
+++ b/.idea/WPD-Auth.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..3e7d9f0
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..4140949
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..a468a99
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..e8f93bf
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..9661ac7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0a77e75..8b729f4 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,7 +5,10 @@
-
+
+
+
+
@@ -18,6 +21,9 @@
+
@@ -29,7 +35,8 @@
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
- "last_opened_file_path": "/Users/diegopajaritograjales/PycharmProjects/WPD-Auth",
+ "git-widget-placeholder": "main",
+ "last_opened_file_path": "C:/xampp/htdocs/java-wpd-auth/WPD-Auth-PR/WPD-Auth",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
diff --git a/pom.xml b/pom.xml
index 14a1474..650e0eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -94,8 +94,13 @@
gson
2.8.5
provided
-
-
+
+
+ org.jetbrains
+ annotations
+ 24.1.0
+
+
diff --git a/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java b/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java
index 0ab8aac..9706ccb 100644
--- a/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java
+++ b/src/main/java/org/waterproofingdata/wpdauth/controller/UsersController.java
@@ -8,10 +8,12 @@ import org.waterproofingdata.wpdauth.dto.UsersResponseDTO;
import org.waterproofingdata.wpdauth.model.Users;
import org.waterproofingdata.wpdauth.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -30,6 +32,16 @@ import io.swagger.annotations.Authorization;
public class UsersController {
@Autowired
private UsersService userService;
+
+ @PutMapping("/update")
+ public ResponseEntity editUser(@RequestBody Users updatedUser) {
+ Users editedUser = userService.editUser(updatedUser);
+ if (editedUser != null) {
+ return ResponseEntity.ok(editedUser);
+ } else {
+ return ResponseEntity.notFound().build();
+ }
+ }
@GetMapping(value = "/{id}")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_INSTITUTION') or hasRole('ROLE_CLIENT')")
diff --git a/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java b/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java
index 307b346..1c7a316 100644
--- a/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java
+++ b/src/main/java/org/waterproofingdata/wpdauth/service/UsersService.java
@@ -6,6 +6,7 @@ import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
+import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.mail.javamail.JavaMailSender;
@@ -48,6 +49,27 @@ public class UsersService {
@Autowired
private AuthenticationManager authenticationManager;
+
+ public Users editUser(@NotNull Users updatedUser) {
+ Users existingUser = usersRepository.findById(updatedUser.getId()).orElse(null);
+ if (existingUser != null) {
+ existingUser.setNickname(updatedUser.getNickname());
+ existingUser.setDateofborn(updatedUser.getDateofborn());
+ existingUser.setGender(updatedUser.getGender());
+ existingUser.setState(updatedUser.getState());
+ existingUser.setCity(updatedUser.getCity());
+ existingUser.setInstitutiontype(updatedUser.getInstitutiontype());
+ existingUser.setInstitution(updatedUser.getInstitution());
+ existingUser.setSecurityquestion(updatedUser.getSecurityquestion());
+ existingUser.setSecurityanswer(updatedUser.getSecurityanswer());
+ existingUser.setTermsofusage(updatedUser.getTermsofusage());
+ existingUser.setAvatar(updatedUser.getAvatar());
+ existingUser.setActive(updatedUser.getActive());
+
+ return usersRepository.save(existingUser);
+ }
+ return null;
+ }
private void addNewUsersEducemadenOrganization(Integer userid, Integer educemadenorganizationsid, UUID uuid_activationkey, Roles role) {
UsersEducemadenOrganizations userEducemadenOrg = new UsersEducemadenOrganizations();