Revize 853bb665
Přidáno uživatelem Michal Linha před asi 4 roky(ů)
src/main/java/vldc/aswi/service/UserManagerImpl.java | ||
---|---|---|
12 | 12 |
import org.springframework.stereotype.Service; |
13 | 13 |
import vldc.aswi.dao.RoleRepository; |
14 | 14 |
import vldc.aswi.dao.UserRepository; |
15 |
import vldc.aswi.domain.Role; |
|
15 | 16 |
import vldc.aswi.domain.User; |
16 | 17 |
import vldc.aswi.model.login.WebCredentials; |
17 | 18 |
|
... | ... | |
57 | 58 |
} |
58 | 59 |
} |
59 | 60 |
|
61 |
/** |
|
62 |
* Converts role name to Spring role name |
|
63 |
* @param role role which name should be converted |
|
64 |
* @return string with Spring role |
|
65 |
*/ |
|
66 |
private String toSpringRole(Role role) { |
|
67 |
return "ROLE_" + role.getName(); |
|
68 |
} |
|
69 |
|
|
60 | 70 |
/** |
61 | 71 |
* Load user details by his username. |
62 | 72 |
* @param username Username of user. |
... | ... | |
72 | 82 |
} |
73 | 83 |
|
74 | 84 |
WebCredentials credentials = new WebCredentials(user.getUsername(), user.getPassword()); |
75 |
credentials.addRole(user.getRole().getName()); |
|
85 |
|
|
86 |
credentials.addRole(toSpringRole(user.getRole())); |
|
76 | 87 |
|
77 | 88 |
return credentials; |
78 | 89 |
} |
Také k dispozici: Unified diff
re #7973 changes of authorization - only admin can view pages assembly_new, assembly_edit and assembly_delete, implemented role name to spring role name converter