package com.skr.mdm.authentication.user;


import com.skr.mdm.authentication.TokenExpireException;
import com.skr.mdm.dto.LoginUserDTO;
import com.skr.mdm.dto.TokenDTO;

/**
 * @author nfq
 * @date 2020/7/16 9:33
 */
public interface UserTokenHandler {

    /**
     * 生成token
     * @param loginUserDTO
     * @return
     */
    TokenDTO createToken(LoginUserDTO loginUserDTO);

    /**
     * 获取用户信息
     * @param jwt
     * @return
     */
    LoginUserDTO getLoginUserByJwt(String jwt) throws TokenExpireException;

    /**
     * 刷新token
     * @param jwt_token
     * @param refresh_token
     * @return
     */
    TokenDTO refreshToken(String jwt_token, String refresh_token);

    /**
     * 清除token缓存
     * @param jwt
     */
    void emptyRedisToken(String jwt);

    /**
     * 退出登录
     * @param jwt
     */
    void signOut(String jwt) throws TokenExpireException;

    /**
     * refreshToken数据库获取信息
     * @param refreshToken
     * @return
     */
    LoginUserDTO getLoginUserByRefreshToken(String refreshToken);
}
