action通过注解的方式授权,当用户没有权限时,在后端如何将未授权信息return给其他的action呢?
9 回复
// 修改密码
@At("/changePWD")
@Ok("json")
@AdaptBy(type = JsonAdaptor.class)
@RequiresPermissions("manager:query1")
public JSONResult changePWD(@Param("..") final JSONObject params, final HttpServletRequest request) {
String oldpassword = params.getString("oldpassword");
String password = params.getString("password");
Subject subject = SecurityUtils.getSubject();
ActiveUser activeUser = (ActiveUser) subject.getPrincipals().getPrimaryPrincipal();
Employee employee = dataService.getUserByBm(activeUser.getEmployeeBm());
if (!ShiroPasswordUtil.getShiroPassword(oldpassword, employee.getAuthsalt(), 1024).equals(employee.getPassword())) {
return JSONResult.errorMsg("旧密码不正确!");
}
String salt = NumberUtil.getStringRandom(6);
employee.setPassword(ShiroPasswordUtil.getShiroPassword(password, salt, 1024));
employee.setAuthsalt(salt);
if (!dataService.updateMyDao(employee)) {
return JSONResult.errorMsg("密码修改失败!");
}
;
return JSONResult.ok();//我想在这里自定义返回我的json格式,注解的好像直接就进不了了,主要想要前端处理json统一一些
}
添加回复
请先登陆