Package cn.iver.interceptor

Source Code of cn.iver.interceptor.AdminInterceptor

package cn.iver.interceptor;

import cn.iver.common.Const;
import cn.iver.model.User;
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-4-4
*/
public class AdminInterceptor implements Interceptor {
    @Override
    public void intercept(ActionInvocation ai) {
        Controller controller = ai.getController();
        User user = controller.getSessionAttr("user");
        if (user != null && Const.ADMIN_EMAIL.equals(user.getStr("email"))){
            ai.invoke();
        }else{
            controller.setAttr("msg", "需要管理员权限");
            controller.renderError(500);
        }
    }
}
TOP

Related Classes of cn.iver.interceptor.AdminInterceptor

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.