mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-29 18:38:32 +08:00
fix 没有工作空间权限时页面循环跳转
This commit is contained in:
parent
94c0946147
commit
dbe9c00332
@ -11,6 +11,7 @@
|
||||
2. 【server】优化 逻辑节点中项目数和脚本数仅显示当前工作空间数量
|
||||
3. 【server】优化 项目编辑和节点分发页面支持快捷配置授权目录
|
||||
4. 【server】优化 项目编辑支持切换节点(快速同步其他节点项目)
|
||||
5. 【server】修复 没有工作空间权限时页面循环跳转(感谢[@王先生](https://gitee.com/whz_gmg1) [Gitee issues I8RR01](https://gitee.com/dromara/Jpom/issues/I8RR01))
|
||||
|
||||
------
|
||||
|
||||
|
@ -25,8 +25,9 @@ package org.dromara.jpom.common;
|
||||
import cn.keepbx.jpom.IJsonMessage;
|
||||
import cn.keepbx.jpom.model.JsonMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.system.AgentException;
|
||||
import org.dromara.jpom.system.AuthorizeException;
|
||||
import org.dromara.jpom.exception.AgentAuthorizeException;
|
||||
import org.dromara.jpom.exception.AgentException;
|
||||
import org.dromara.jpom.exception.PermissionException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@ -47,8 +48,8 @@ public class GlobalDefaultExceptionHandler extends BaseExceptionHandler {
|
||||
*
|
||||
* @param e 异常
|
||||
*/
|
||||
@ExceptionHandler({AuthorizeException.class})
|
||||
public IJsonMessage<String> delExceptionHandler(AuthorizeException e) {
|
||||
@ExceptionHandler({AgentAuthorizeException.class})
|
||||
public IJsonMessage<String> delExceptionHandler(AgentAuthorizeException e) {
|
||||
return e.getJsonMessage();
|
||||
}
|
||||
|
||||
@ -70,4 +71,15 @@ public class GlobalDefaultExceptionHandler extends BaseExceptionHandler {
|
||||
}
|
||||
return new JsonMessage<>(405, e.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* 权限异常 需要退出登录
|
||||
*
|
||||
* @param e 异常
|
||||
* @return json
|
||||
*/
|
||||
@ExceptionHandler({PermissionException.class})
|
||||
public IJsonMessage<String> doPermissionException(PermissionException e) {
|
||||
return new JsonMessage<>(ServerConst.AUTHORIZE_TIME_OUT_CODE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.keepbx.jpom.model.JsonMessage;
|
||||
import com.alibaba.fastjson2.TypeReference;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.jpom.system.AgentException;
|
||||
import org.dromara.jpom.exception.AgentException;
|
||||
import org.dromara.jpom.transport.INodeInfo;
|
||||
import org.dromara.jpom.transport.TransformServer;
|
||||
|
||||
|
@ -48,8 +48,8 @@ import org.dromara.jpom.func.assets.model.MachineNodeModel;
|
||||
import org.dromara.jpom.func.assets.server.MachineNodeServer;
|
||||
import org.dromara.jpom.model.data.NodeModel;
|
||||
import org.dromara.jpom.model.user.UserModel;
|
||||
import org.dromara.jpom.system.AgentException;
|
||||
import org.dromara.jpom.system.AuthorizeException;
|
||||
import org.dromara.jpom.exception.AgentException;
|
||||
import org.dromara.jpom.exception.AgentAuthorizeException;
|
||||
import org.dromara.jpom.system.ServerConfig;
|
||||
import org.dromara.jpom.transport.*;
|
||||
import org.dromara.jpom.util.StrictSyncFinisher;
|
||||
@ -650,7 +650,7 @@ public class NodeForward {
|
||||
if (data instanceof JsonMessage) {
|
||||
JsonMessage<?> jsonMessage = (JsonMessage<?>) data;
|
||||
if (jsonMessage.getCode() == Const.AUTHORIZE_ERROR) {
|
||||
throw new AuthorizeException(new JsonMessage<>(jsonMessage.getCode(), jsonMessage.getMsg()));
|
||||
throw new AgentAuthorizeException(new JsonMessage<>(jsonMessage.getCode(), jsonMessage.getMsg()));
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("消息转换异常");
|
||||
|
@ -37,7 +37,7 @@ import org.dromara.jpom.service.h2db.BaseNodeService;
|
||||
import org.dromara.jpom.service.h2db.BaseWorkspaceService;
|
||||
import org.dromara.jpom.service.node.NodeService;
|
||||
import org.dromara.jpom.service.user.UserBindWorkspaceService;
|
||||
import org.dromara.jpom.system.AgentException;
|
||||
import org.dromara.jpom.exception.AgentException;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
|
@ -20,7 +20,7 @@
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.dromara.jpom.system;
|
||||
package org.dromara.jpom.exception;
|
||||
|
||||
import cn.keepbx.jpom.IJsonMessage;
|
||||
import cn.keepbx.jpom.model.JsonMessage;
|
||||
@ -31,10 +31,10 @@ import cn.keepbx.jpom.model.JsonMessage;
|
||||
* @author bwcx_jzy
|
||||
* @since 2019/4/17
|
||||
*/
|
||||
public class AuthorizeException extends RuntimeException {
|
||||
public class AgentAuthorizeException extends RuntimeException {
|
||||
private final JsonMessage<String> jsonMessage;
|
||||
|
||||
public AuthorizeException(JsonMessage<String> jsonMessage) {
|
||||
public AgentAuthorizeException(JsonMessage<String> jsonMessage) {
|
||||
super(jsonMessage.getMsg());
|
||||
this.jsonMessage = jsonMessage;
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.dromara.jpom.system;
|
||||
package org.dromara.jpom.exception;
|
||||
|
||||
/**
|
||||
* agent 插件端异常
|
@ -0,0 +1,13 @@
|
||||
package org.dromara.jpom.exception;
|
||||
|
||||
/**
|
||||
* 权限异常
|
||||
*
|
||||
* @author bwcx_jzy
|
||||
* @since 23/12/29 029
|
||||
*/
|
||||
public class PermissionException extends RuntimeException {
|
||||
public PermissionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -54,8 +54,8 @@ import org.dromara.jpom.model.data.NodeModel;
|
||||
import org.dromara.jpom.model.user.UserModel;
|
||||
import org.dromara.jpom.service.h2db.BaseDbService;
|
||||
import org.dromara.jpom.service.node.NodeService;
|
||||
import org.dromara.jpom.system.AgentException;
|
||||
import org.dromara.jpom.system.AuthorizeException;
|
||||
import org.dromara.jpom.exception.AgentException;
|
||||
import org.dromara.jpom.exception.AgentAuthorizeException;
|
||||
import org.dromara.jpom.system.ServerConfig;
|
||||
import org.dromara.jpom.system.db.InitDb;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@ -251,7 +251,7 @@ public class MachineNodeServer extends BaseDbService<MachineNodeModel> implement
|
||||
}
|
||||
jsonObject.put("networkDelay", networkTime);
|
||||
this.saveStatInfo(machineNodeModel, jsonObject);
|
||||
} catch (AuthorizeException agentException) {
|
||||
} catch (AgentAuthorizeException agentException) {
|
||||
this.updateStatus(machineNodeModel, 2, agentException.getMessage());
|
||||
} catch (AgentException e) {
|
||||
this.updateStatus(machineNodeModel, 0, e.getMessage());
|
||||
|
@ -45,8 +45,8 @@ import org.dromara.jpom.model.data.WorkspaceModel;
|
||||
import org.dromara.jpom.model.user.UserModel;
|
||||
import org.dromara.jpom.service.node.NodeService;
|
||||
import org.dromara.jpom.service.system.WorkspaceService;
|
||||
import org.dromara.jpom.system.AgentException;
|
||||
import org.dromara.jpom.system.AuthorizeException;
|
||||
import org.dromara.jpom.exception.AgentException;
|
||||
import org.dromara.jpom.exception.AgentAuthorizeException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@ -263,10 +263,10 @@ public abstract class BaseNodeService<T extends BaseNodeModel> extends BaseGloba
|
||||
AgentException agentException = (AgentException) e;
|
||||
log.error("{} 同步失败 {}", nodeModelName, agentException.getMessage());
|
||||
return "同步失败" + agentException.getMessage();
|
||||
} else if (e instanceof AuthorizeException) {
|
||||
AuthorizeException authorizeException = (AuthorizeException) e;
|
||||
log.error("{} 授权异常 {}", nodeModelName, authorizeException.getMessage());
|
||||
return "授权异常" + authorizeException.getMessage();
|
||||
} else if (e instanceof AgentAuthorizeException) {
|
||||
AgentAuthorizeException agentAuthorizeException = (AgentAuthorizeException) e;
|
||||
log.error("{} 授权异常 {}", nodeModelName, agentAuthorizeException.getMessage());
|
||||
return "授权异常" + agentAuthorizeException.getMessage();
|
||||
}
|
||||
// else if (e instanceof JSONException) {
|
||||
// log.error("{} 消息解析失败 {}", nodeModelName, e.getMessage());
|
||||
|
@ -35,6 +35,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
||||
import org.dromara.jpom.common.BaseServerController;
|
||||
import org.dromara.jpom.common.Const;
|
||||
import org.dromara.jpom.common.ServerConst;
|
||||
import org.dromara.jpom.exception.PermissionException;
|
||||
import org.dromara.jpom.model.BaseWorkspaceModel;
|
||||
import org.dromara.jpom.model.PageResultDto;
|
||||
import org.dromara.jpom.model.user.UserModel;
|
||||
@ -262,7 +263,9 @@ public abstract class BaseWorkspaceService<T extends BaseWorkspaceModel> extends
|
||||
// 查询绑定的权限
|
||||
UserBindWorkspaceService userBindWorkspaceService = SpringUtil.getBean(UserBindWorkspaceService.class);
|
||||
boolean exists = userBindWorkspaceService.exists(userModel, workspaceId);
|
||||
Assert.state(exists, "没有对应的工作空间权限");
|
||||
if (exists) {
|
||||
throw new PermissionException("没有对应的工作空间权限");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,7 +41,7 @@ import org.dromara.jpom.model.user.UserModel;
|
||||
import org.dromara.jpom.service.h2db.BaseNodeService;
|
||||
import org.dromara.jpom.service.node.NodeService;
|
||||
import org.dromara.jpom.service.system.WorkspaceService;
|
||||
import org.dromara.jpom.system.AgentException;
|
||||
import org.dromara.jpom.exception.AgentException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -155,7 +155,7 @@ function wrapResult(response) {
|
||||
return res;
|
||||
}
|
||||
|
||||
function toLogin(res, response, timeout = 100) {
|
||||
function toLogin(res, response, timeout = 2000) {
|
||||
notification.warn({
|
||||
message: "提示信息 " + (pro ? "" : response.config.url),
|
||||
description: res.msg,
|
||||
|
Loading…
Reference in New Issue
Block a user