Skip to content

Commit

Permalink
optimize AdminInterceptor and upgrade jboot version
Browse files Browse the repository at this point in the history
  • Loading branch information
yangfuhai committed Aug 14, 2020
1 parent f2bd7a3 commit 162c3ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,13 @@ public void intercept(Invocation inv) {

String uid = CookieUtil.get(inv.getController(), JPressConsts.COOKIE_UID);
if (StrUtil.isBlank(uid)) {

//当用户未配置自定义登录页面,直接跳转到登录页面
if (JPressConfig.DEFAULT_LOGIN_PAGE.equals(JPressConfig.me.getAdminLoginPage())) {
inv.getController().redirect(JPressConfig.DEFAULT_LOGIN_PAGE);
}
//如果用户配置了自定义的登录页面,则直接渲染404,否则会暴露用户配置的登录页面
//这样一来,用户配置的后台登录页面就没有意义了
else {
inv.getController().renderError(404);
}

redirectLoginPage(inv);
return;
}

if (!SessionUtils.isLoginedOk(Long.valueOf(uid))){
CookieUtil.remove(inv.getController(),JPressConsts.COOKIE_UID);
inv.invoke();
redirectLoginPage(inv);
return;
}

Expand All @@ -102,4 +92,17 @@ public void intercept(Invocation inv) {
}


private void redirectLoginPage(Invocation inv){
//当用户未配置自定义登录页面,直接跳转到登录页面
if (JPressConfig.DEFAULT_LOGIN_PAGE.equals(JPressConfig.me.getAdminLoginPage())) {
inv.getController().redirect(JPressConfig.DEFAULT_LOGIN_PAGE);
}
//如果用户配置了自定义的登录页面,则直接渲染404,否则会暴露用户配置的登录页面
//这样一来,用户配置的后台登录页面就没有意义了
else {
inv.getController().renderError(404);
}
}


}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<properties>
<jdk.version>1.8</jdk.version>
<jboot.version>3.3.4</jboot.version>
<jboot.version>3.3.6</jboot.version>
<jfinal-weixin.version>2.6</jfinal-weixin.version>
<jjwt.version>0.9.1</jjwt.version>
<logback.version>1.2.3</logback.version>
Expand Down

0 comments on commit 162c3ce

Please sign in to comment.