package com.persagy.dmp.auth.service.impl;

import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * BOSS 鉴权实现类
 * 校验token，并从token中获取上下文信息
 * @author Charlie Yu
 * @date 2021-11-02
 */
@Slf4j
public class BossAuthServiceImpl extends AbstractAuthServiceImpl{

    @Override
    public boolean validateLogin(HttpServletRequest request, HttpServletResponse response) {
        // 获取token
        String token = request.getHeader("token");
        if(StrUtil.isBlank(token)) {
            log.error("未获取到token!");
            return false;
        }
        return super.validateLogin(request, response);
    }

    @Override
    public void loginSuccess(HttpServletRequest request, HttpServletResponse response) {
        loadContextByRequest(request);
    }
}
