Commit d55801a6 by wangzhen

Refactor the classes of the RBAC to PermissionService.

1 parent 82665a43
......@@ -8,6 +8,8 @@ import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.resource.NoResourceFoundException;
@Slf4j
@RestControllerAdvice
......@@ -19,6 +21,15 @@ public class ErrorHandler {
return Result.error(500, e.getMessage());
}
@ExceptionHandler(NoResourceFoundException.class)
public ModelAndView handleNoResourceFoundException(Exception e) {
log.error("Unknown Exception was thrown!", e);
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("404");
return modelAndView;
}
@ExceptionHandler(BaseException.class)
public Result<Object> handleCustomException(BaseException e) {
log.warn("Biz Exception was thrown!", e);
......
......@@ -68,8 +68,8 @@ public class ShiroConfig {
/* 3. common url start */
shiroFilter.setLoginUrl("/auth/login");
shiroFilter.setSuccessUrl("/auth/index");
shiroFilter.setUnauthorizedUrl("/auth/401");
shiroFilter.setSuccessUrl("/shiro/index");
shiroFilter.setUnauthorizedUrl("/shiro/401");
/* common url end */
return shiroFilter;
......
......@@ -19,16 +19,6 @@ public class LoginController {
@PostMapping("/login")
public String doLogin() {
return "redirect:/shiro/info";
}
@GetMapping("/index")
public String index() {
return "index";
}
@GetMapping("/401")
public String page401() {
return "401";
return "/shiro/info";
}
}
......@@ -14,6 +14,7 @@ import org.apache.shiro.subject.Subject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
@RestController
@RequestMapping("/shiro")
......@@ -84,4 +85,18 @@ public class ShiroController {
public Result<SysUser> getUsers() {
return Result.success(permissionService.getAllUsers());
}
@GetMapping("/index")
public ModelAndView index() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("index");
return modelAndView;
}
@GetMapping("/401")
public ModelAndView page401() {
ModelAndView modelAndView = new ModelAndView();
modelAndView.setViewName("401");
return modelAndView;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!