#include "FLoginStateBase.h"

#include "Common/CsdkErrorCode.h"
#include "Tools/CsdkCommonTools.h"
#include "User/Tool/UserTool.h"


void FLoginStateBase::HttpCallback(const int32 ErrorCode,const FString& ErrorMsg,const heroim::client::v3beta::dto::auth::LoginResponse& Resp) const
{
	if(ErrorCode == ECsdkErrorCode::Success)
	{
		FCsdkCommonTools::GetUserManager().SetCurrentUser(CsdkUserTool::ConvertUser(Resp.user()));
		Manager.Token = (STD_STRING_TO_FSTRING(Resp.token()));
		SwitchState(ELoginStateId::Link);
	}
	else
	{
		CallLoginCallback(ErrorCode, ErrorMsg);
	}
}
