Revize 38350f55
Přidáno uživatelem Michal Linha před asi 4 roky(ů)
src/main/java/vldc/aswi/service/ConfigurationManagerImpl.java | ||
---|---|---|
5 | 5 |
import org.springframework.context.event.ContextRefreshedEvent; |
6 | 6 |
import org.springframework.context.event.EventListener; |
7 | 7 |
import org.springframework.core.annotation.Order; |
8 |
import org.springframework.security.authentication.AnonymousAuthenticationToken; |
|
9 |
import org.springframework.security.core.Authentication; |
|
10 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
11 | 8 |
import org.springframework.stereotype.Service; |
12 | 9 |
import vldc.aswi.dao.*; |
13 | 10 |
import vldc.aswi.dao.parameter.ParameterInConfigurationRepository; |
... | ... | |
83 | 80 |
*/ |
84 | 81 |
@Override |
85 | 82 |
public List<Configuration> getConfigurations() { |
86 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
|
87 |
String username; |
|
88 |
if (!(authentication instanceof AnonymousAuthenticationToken)) { |
|
89 |
username = authentication.getName(); |
|
90 |
} |
|
91 |
else { |
|
83 |
String username = AuthControl.getUserName(); |
|
84 |
if (username == null) { |
|
92 | 85 |
// TODO: 04.05.2020 error message, user not authenticated |
93 |
return null; |
|
94 | 86 |
} |
87 |
|
|
95 | 88 |
User user = userRepository.findByUsername(username); |
96 | 89 |
|
97 | 90 |
return configurationRepository.getByUserEquals(user); |
... | ... | |
167 | 160 |
* @return saved configuration |
168 | 161 |
*/ |
169 | 162 |
private Configuration addConfiguration(Configuration newConfiguration) { |
170 |
Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); |
|
171 | 163 |
String username = AuthControl.getUserName(); |
172 | 164 |
if (username == null) { |
173 | 165 |
// TODO: 04.05.2020 error message, user not authenticated |
Také k dispozici: Unified diff
re #7978 minor code improvements