Announcement

Collapse
No announcement yet.

How does PreLogin modify ErrorMessage reference value after validation permission(Varest) request

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How does PreLogin modify ErrorMessage reference value after validation permission(Varest) request

    How does PreLogin modify the ErrorMessage reference value after the validation permission (using Varest) requested
    In PreLogin, you must modify the value of the ErrorMessage reference object to reject the client connection.So I tried the following:
    1:
    gamemode.h
    Code:
    UFUNCTION(BlueprintImplementableEvent,Category = "CPPGM")
    void AuthUser(const FUniqueNetIdRepl& UniqueId,UPARAM(ref) FString& ErrorMessage,const FString& UserToken);
    UFUNCTION(BlueprintCallable,Category = "CPPGM") void AuthUserEvent(const FUniqueNetIdRepl& UniqueId,UPARAM(ref) FString& ErrorMessage);
    gamemode.cpp


    Code:
    void AMyCPPGM::AuthUserEvent(const FUniqueNetIdRepl& UniqueId,FString& ErrorMessage)
    {
    if (ErrorMessage.Equals("")) { ErrorMessage = TEXT("Authentication failed!");
    }
    FGameModeEvents::GameModePreLoginEvent.Broadcast(this, UniqueId, ErrorMessage);
    }
    
    void AMyCPPGM::PreLogin(const FString& Options, const FString& Address, const FUniqueNetIdRepl& UniqueId, FString& ErrorMessage)
    { // Super::PreLogin(Options, Address, UniqueId, ErrorMessage); if (NowPlayers>=MaxPlayer)
    { ErrorMessage = TEXT("Plays Full Access denied");
    }
    const FString password = UGameplayStatics::ParseOption(Options, TEXT("UUID"))
    ; const FString& token = UGameplayStatics::ParseOption(Options, TEXT("token"));
    const bool bUniqueIdCheckOk = (!UniqueId.IsValid() || (UniqueId.GetType() == UOnlineEngineInterface::Get()->GetDefaultOnlineSubsystemName()));
    if (bUniqueIdCheckOk && password == UUID)
    { ErrorMessage = GameSession->ApproveLogin(Options);
    }
    else
    {
    ErrorMessage = TEXT("Access denied"); UE_LOG(LogTemp,Warning,TEXT("Access denied!!!!!"))
    }
    if (ErrorMessage.Equals(""))
    {
    //不为空则上面验证成功,下面进行身份验证,否则直接广播委托回去失败!
    //这里的ErrorMessage必须是地址,修改的是地址的内容才有效,修改值是没有效果的
    GLog->Log("<<<<<<<<<<<<<<<<"); GLog->Log(ErrorMessage);
    // MyReceiveDelegateEvent.ExecuteIfBound(UniqueId,token,ErrorMessage);
    this->AuthUser(UniqueId,ErrorMessage,token);
    }
    else
    {
    FGameModeEvents::GameModePreLoginEvent.Broadcast(this, UniqueId, ErrorMessage);
    }
    // FGameModeEvents::GameModePreLoginEvent.Broadcast(this, UniqueId, ErrorMessage);
    }
    BP:
    The reference does not return a value
    The reference does not return a value
    You can't use
    2:
    Click image for larger version  Name:	H@X@73VT`XP0P`B$GK77TJB.png Views:	0 Size:	127.2 KB ID:	1826028
    Click image for larger version  Name:	QV$J5V3OU13K2I(0Q_MVCNB.png Views:	0 Size:	157.7 KB ID:	1826029

    Varest requests part


    Click image for larger version  Name:	6JC1Z}HGVM{9ZU_`_5JV_9F.png Views:	0 Size:	315.1 KB ID:	1826030
    My English is not very good and c++ is not very good, please help me, I would be very grateful, I have spent 3 days on this problem
    Attached Files
    Last edited by 夏之の殇; 10-26-2020, 04:11 AM.
Working...
X