Revision 57907
Added by Ioannis Diplas over 4 years ago
RepositoryController.java | ||
---|---|---|
8 | 8 |
import eu.dnetlib.repo.manager.service.RepositoryServiceImpl; |
9 | 9 |
import io.swagger.annotations.Api; |
10 | 10 |
import org.json.JSONException; |
11 |
import org.mitre.openid.connect.model.OIDCAuthenticationToken; |
|
11 | 12 |
import org.springframework.beans.factory.annotation.Autowired; |
12 | 13 |
import org.springframework.http.MediaType; |
13 | 14 |
import org.springframework.security.access.prepost.PostAuthorize; |
14 | 15 |
import org.springframework.security.access.prepost.PreAuthorize; |
15 | 16 |
import org.springframework.security.core.Authentication; |
17 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
16 | 18 |
import org.springframework.web.bind.annotation.*; |
17 | 19 |
|
18 | 20 |
import java.io.IOException; |
... | ... | |
49 | 51 |
public List<RepositorySnippet> getRepositoriesOfUser(@PathVariable("userEmail") String userEmail, |
50 | 52 |
@PathVariable("page") String page, |
51 | 53 |
@PathVariable("size") String size) throws JSONException, IOException { |
54 |
userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
52 | 55 |
return repositoryService.getRepositoriesSnippetOfUser(userEmail, page, size); |
53 | 56 |
} |
54 | 57 |
|
... | ... | |
172 | 175 |
public List<String> getUrlsOfUserRepos(@PathVariable("user_email") String userEmail, |
173 | 176 |
@PathVariable("page") String page, |
174 | 177 |
@PathVariable("size") String size) throws JSONException { |
178 |
userEmail = ((OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication()).getUserInfo().getEmail(); |
|
175 | 179 |
return repositoryService.getUrlsOfUserRepos(userEmail, page, size); |
176 | 180 |
} |
177 | 181 |
|
Also available in: Unified diff
New mapping for RepositorySnippet + Using SecurityContext to get the email of user