fix move to request scope
@@ -88,6 +88,7 @@ public class RoleQueryHelper {
public Set<String> build(final SearchRequestType searchRequestType) {
final Set<String> roleSet = new HashSet<>();
final HttpServletRequest request = LaRequestUtil.getOptionalRequest().orElse(null);
+ final FessConfig fessConfig = ComponentUtil.getFessConfig();
final boolean isApiRequest =
!SearchRequestType.SEARCH.equals(searchRequestType) && !SearchRequestType.ADMIN_SEARCH.equals(searchRequestType);
@@ -121,9 +122,7 @@ public class RoleQueryHelper {
if (isApiRequest) {
processAccessToken(request, roleSet);
}
- }
- final FessConfig fessConfig = ComponentUtil.getFessConfig();
final RequestManager requestManager = ComponentUtil.getRequestManager();
try {
requestManager.findUserBean(FessUserBean.class)
@@ -135,9 +134,14 @@ public class RoleQueryHelper {
roleSet.addAll(fessConfig.getSearchGuestPermissionList());
});
} catch (final RuntimeException e) {
+ try {
requestManager.findLoginManager(FessUserBean.class).ifPresent(manager -> manager.logout());
+ } catch (Exception e1) {
+ // ignore
+ }
throw e;
}
+ }
if (defaultRoleList != null) {
roleSet.addAll(defaultRoleList);
