Package cn.iver.interceptor

Source Code of cn.iver.interceptor.UserCheckInterceptor

package cn.iver.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.jfinal.core.Controller;
import com.jfinal.kit.StringKit;

/**
* Created with IntelliJ IDEA.
* Author: StevenChow
* Date: 13-5-7
*/
public class UserCheckInterceptor implements Interceptor {
    @Override
    public void intercept(ActionInvocation ai) {
        Controller controller = ai.getController();
        String userID = controller.getSessionAttr("userID").toString();
        if(StringKit.notBlank(userID) && userID.equals(controller.getPara(0, "0") + "")){
            ai.invoke();
        }else{
            controller.setAttr("msg", "只有该登录用户本人才有权操作");
            controller.renderError(500);
        }
    }
}
TOP

Related Classes of cn.iver.interceptor.UserCheckInterceptor

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.