获取角色
This commit is contained in:
parent
6902ace558
commit
e2795eb385
|
|
@ -32,6 +32,7 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
public class MgrAuthApi {
|
||||
|
|
@ -71,6 +72,10 @@ public class MgrAuthApi {
|
|||
user.setUserid(SecurityUtils.getUserId());
|
||||
user.setUsername(SecurityUtils.getUsername());
|
||||
String roleCode = (String) SecureManager.getSubjectData().get("roleCode");
|
||||
Optional<String> firstElement = user.getRoles().stream().findFirst();
|
||||
if (firstElement.isPresent()) {
|
||||
roleCode = firstElement.get();
|
||||
}
|
||||
if (ObjectUtil.isEmpty(roleCode)) {
|
||||
throw new ServiceException(I18n.getMessage("auth_user_no_role_code", new Object[0]));
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue