Revision 57542
Added by Michele Artini over 4 years ago
UserController.java | ||
---|---|---|
5 | 5 |
|
6 | 6 |
import org.apache.commons.codec.digest.DigestUtils; |
7 | 7 |
import org.springframework.beans.factory.annotation.Autowired; |
8 |
import org.springframework.security.core.Authentication; |
|
9 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
10 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
8 |
import org.springframework.web.bind.annotation.GetMapping; |
|
9 |
import org.springframework.web.bind.annotation.PostMapping; |
|
11 | 10 |
import org.springframework.web.bind.annotation.RequestParam; |
12 | 11 |
import org.springframework.web.bind.annotation.RestController; |
13 | 12 |
|
14 | 13 |
import eu.dnetlib.organizations.model.User; |
14 |
import eu.dnetlib.organizations.model.view.UserView; |
|
15 | 15 |
import eu.dnetlib.organizations.repository.UserRepository; |
16 |
import eu.dnetlib.organizations.repository.readonly.UserViewRepository; |
|
16 | 17 |
import eu.dnetlib.organizations.utils.OpenOrgsConstants; |
17 | 18 |
|
18 | 19 |
@RestController |
... | ... | |
22 | 23 |
|
23 | 24 |
@Autowired |
24 | 25 |
private UserRepository userRepository; |
26 |
@Autowired |
|
27 |
private UserViewRepository userViewRepository; |
|
25 | 28 |
|
26 |
@RequestMapping(value = "/api/user/current", method = RequestMethod.GET) |
|
27 |
public UserInfo utente(final Authentication authentication) { |
|
28 |
return UserInfo.generate(authentication); |
|
29 |
} |
|
30 |
|
|
31 |
@RequestMapping(value = "/public_api/newUser", method = RequestMethod.POST) |
|
32 |
public Map<String, Integer> utente(final @RequestParam String email) { |
|
29 |
@PostMapping(value = "/public_api/newUser") |
|
30 |
public Map<String, Integer> newUser(final @RequestParam String email) { |
|
33 | 31 |
final Map<String, Integer> res = new HashMap<>(); |
34 | 32 |
if (userRepository.existsById(email)) { |
35 | 33 |
res.put("status", 2); |
... | ... | |
45 | 43 |
return res; |
46 | 44 |
} |
47 | 45 |
|
46 |
@GetMapping("/api/users") |
|
47 |
public Iterable<UserView> users() { |
|
48 |
return userViewRepository.findAll(); |
|
49 |
} |
|
50 |
|
|
48 | 51 |
} |
Also available in: Unified diff
users management