Revize fab2885e
Přidáno uživatelem Michal Linha před asi 4 roky(ů)
src/main/java/vldc/aswi/web/controller/AssemblyController.java | ||
---|---|---|
1 | 1 |
package vldc.aswi.web.controller; |
2 | 2 |
|
3 | 3 |
import org.springframework.beans.factory.annotation.Autowired; |
4 |
import org.springframework.security.authentication.AnonymousAuthenticationToken; |
|
5 |
import org.springframework.security.core.Authentication; |
|
6 |
import org.springframework.security.core.GrantedAuthority; |
|
7 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
4 | 8 |
import org.springframework.stereotype.Controller; |
5 | 9 |
import org.springframework.ui.ModelMap; |
6 | 10 |
import org.springframework.validation.BindingResult; |
... | ... | |
12 | 16 |
import org.springframework.web.bind.annotation.RequestParam; |
13 | 17 |
import org.springframework.web.servlet.ModelAndView; |
14 | 18 |
import org.springframework.web.servlet.mvc.support.RedirectAttributes; |
15 |
import vldc.aswi.domain.Assembly; |
|
16 |
import vldc.aswi.domain.Configuration; |
|
17 |
import vldc.aswi.domain.Location; |
|
18 |
import vldc.aswi.domain.Operator; |
|
19 |
import vldc.aswi.domain.*; |
|
19 | 20 |
import vldc.aswi.domain.parameter.Parameter; |
20 | 21 |
import vldc.aswi.domain.parameter.ParameterInConfiguration; |
21 | 22 |
import vldc.aswi.service.*; |
22 | 23 |
import vldc.aswi.service.parameter.ParameterManager; |
23 | 24 |
import vldc.aswi.service.parameter.ParameterTypeManager; |
25 |
import vldc.aswi.utils.AuthControl; |
|
24 | 26 |
import vldc.aswi.validators.AssemblyValidator; |
25 | 27 |
import vldc.aswi.utils.Utils; |
26 | 28 |
|
27 | 29 |
import javax.validation.Valid; |
28 | 30 |
import java.util.ArrayList; |
29 | 31 |
import java.util.Comparator; |
32 |
import java.util.Set; |
|
33 |
import java.util.stream.Collectors; |
|
30 | 34 |
|
31 | 35 |
/** |
32 | 36 |
* Controller for assemblies and configurations |
... | ... | |
104 | 108 |
|
105 | 109 |
Assembly assembly = this.assemblyManager.getAssemblyById(Long.parseLong(id)); |
106 | 110 |
|
111 |
// TODO: 04.05.2020 error page when id doesn't exist |
|
112 |
|
|
113 |
String roleName = AuthControl.getRoleName(); |
|
114 |
|
|
115 |
if (roleName == null) { |
|
116 |
// TODO: 04.05.2020 error message, user not authenticated |
|
117 |
} |
|
118 |
|
|
119 |
Role role = roleManager.getRole(roleName); |
|
120 |
|
|
121 |
if (!assembly.getRoles().contains(role)) { |
|
122 |
// TODO: 04.05.2020 Error page, wrong role |
|
123 |
return new ModelAndView("redirect:/"); |
|
124 |
} |
|
125 |
|
|
107 | 126 |
Configuration configuration = new Configuration(); |
108 | 127 |
|
109 | 128 |
configuration.setAssembly(assembly); |
Také k dispozici: Unified diff
re #7978 added functionality of only showing assemblies with correct role (same as user), added functionality of showing only logged in users's configurations in "Rychle k"