|
|
|
@ -1,10 +1,11 @@
|
|
|
|
|
package com.dsideal.QingLong.Interceptor;
|
|
|
|
|
|
|
|
|
|
import com.dsideal.QingLong.Util.CommonUtil;
|
|
|
|
|
import com.dsideal.QingLong.DataShare.Model.DataShareModel;
|
|
|
|
|
import com.dsideal.QingLong.Util.SessionKit;
|
|
|
|
|
import com.jfinal.aop.Interceptor;
|
|
|
|
|
import com.jfinal.aop.Invocation;
|
|
|
|
|
import com.jfinal.core.Controller;
|
|
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 是不是登录正确?
|
|
|
|
@ -13,6 +14,8 @@ import com.jfinal.core.Controller;
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class IsLoginInterceptor implements Interceptor {
|
|
|
|
|
DataShareModel dm = new DataShareModel();
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void intercept(Invocation inv) {
|
|
|
|
|
//正常的登录验证逻辑代码
|
|
|
|
@ -31,18 +34,30 @@ public class IsLoginInterceptor implements Interceptor {
|
|
|
|
|
inv.invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//1、读取Session
|
|
|
|
|
boolean isTrue;
|
|
|
|
|
if ((SessionKit.get(con.getRequest(), con.getResponse(), "person_id") == null)) {
|
|
|
|
|
isTrue = false;
|
|
|
|
|
|
|
|
|
|
boolean isTrue = false;
|
|
|
|
|
//检查是不是header的Authorization中有合法Token
|
|
|
|
|
String Authorization = con.getRequest().getHeader("Authorization");
|
|
|
|
|
if (Authorization != null) {
|
|
|
|
|
Record record = dm.checkToken(Authorization);
|
|
|
|
|
System.out.println(record);
|
|
|
|
|
if (record.getBoolean("success")) {
|
|
|
|
|
isTrue = true;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
isTrue = true;
|
|
|
|
|
//1、读取Session
|
|
|
|
|
if ((SessionKit.get(con.getRequest(), con.getResponse(), "person_id") == null)) {
|
|
|
|
|
isTrue = false;
|
|
|
|
|
} else {
|
|
|
|
|
isTrue = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isTrue) {
|
|
|
|
|
inv.invoke();
|
|
|
|
|
} else {
|
|
|
|
|
//con.renderJson(CommonUtil.returnMessageJson(false, "此接口需要登录后操作!"));
|
|
|
|
|
con.redirect("/QingLong/");
|
|
|
|
|
con.renderJson(com.dsideal.QingLong.Util.CommonUtil.returnMessageJson(false, "此接口需要登录后操作!"));
|
|
|
|
|
//con.redirect("/QingLong/");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|