Browse Source

Test failed. Still trying to work out secured endpoints

JaseG256 6 years ago
parent
commit
8628192275

+ 8
- 8
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Controller/UserController.java View File

7
 import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.web.bind.annotation.*;
8
 import org.springframework.web.bind.annotation.*;
9
 
9
 
10
+import java.util.Optional;
11
+
10
 @RestController
12
 @RestController
11
 @RequestMapping(path = "/user")
13
 @RequestMapping(path = "/user")
12
 public class UserController {
14
 public class UserController {
23
         return ob.writeValueAsString(user);
25
         return ob.writeValueAsString(user);
24
     }
26
     }
25
 
27
 
26
-    @GetMapping(path="/all")
27
-    public @ResponseBody Iterable<User> getAllUser(){
28
-        //this returns a JSON or XML with users
29
-        return userRepository.findAll();
28
+    @GetMapping(path="/userName")
29
+    public Optional<User> findByUserName(@RequestParam("name") String userName) {
30
+        return userRepository.findByUsername(userName);
30
     }
31
     }
31
 
32
 
32
-    @GetMapping(path="/all")
33
-    public @ResponseBody Iterable<User> getAllUser(){
34
-        //this returns a JSON or XML with users
35
-        return userRepository.findAll();
33
+    @GetMapping(path="/email")
34
+    public Optional<User> findByEmail(@RequestParam("email") String email) {
35
+        return userRepository.findByEmail(email);
36
     }
36
     }
37
 
37
 
38
 }
38
 }