package com.fdkankan.common.user;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class SSOLoginHelper {
    @Autowired
    private SSOLoginStore ssoLoginStore;
    public  SSOUser loginCheck(String sessionId) {
        if (sessionId != null && sessionId.trim().length() > 0) {
            SSOUser ssoUser = ssoLoginStore.get(sessionId);
            if (ssoUser != null) {
                return ssoUser;
            }
        }
        return null;
    }

    public void login(String token, SSOUser ssoUser) {
        ssoLoginStore.put(token, ssoUser);
    }

    public  void logout(String sessionId) {
        ssoLoginStore.remove(sessionId);
    }
}
