package com.casic.missiles.modular.system.handler;

import com.casic.missiles.core.handler.BizCheckLoginHandler;
import com.casic.missiles.core.shiro.ShiroUser;
import com.casic.missiles.core.util.ToolUtil;
import org.apache.shiro.authc.LockedAccountException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class LoginCheckHandler implements BizCheckLoginHandler {
    @Value("${smartcity.leaderRoleName}")
    private String leaderRoleName;
    @Value("${smartcity.memberRoleName}")
    private String memberRoleName;
    @Value("${smartcity.appRoleName}")
    private String appRoleName;

    @Override
    public void checkUser(ShiroUser shiroUser, Boolean isApp) {
        if (isApp) {
            if (!shiroUser.getRoleTips().contains(leaderRoleName) && !shiroUser.getRoleTips().contains(memberRoleName)&& !shiroUser.getRoleTips().contains(appRoleName))
            throw new LockedAccountException("当前用户未授权，请联系管理员");
        }
    }
}
