Dedicated Server PreLogin, Login, PostLogin

I have a specific game mode when starting a connection to the server.

I would like to validate a user connection base on its username and password.

When I launch the client, The PreLogin function is automatically called, which is ok.

void AKGameMode_Menu::PreLogin(const FString& Options, const FString& Address, const TSharedPtr<const FUniqueNetId>& UniqueId, FString& ErrorMessage)
{
	Super::PreLogin(Options, Address, UniqueId, ErrorMessage);
}

APlayerController* AKGameMode_Menu::Login(class UPlayer* NewPlayer, ENetRole InRemoteRole, const FString& Portal, const FString& Options, const TSharedPtr<const FUniqueNetId>& UniqueId, FString& ErrorMessage)
{
	return Super::Login(NewPlayer, InRemoteRole, Portal, Options, UniqueId, ErrorMessage);
}

void AKGameMode_Menu::PostLogin(APlayerController* NewPlayer)
{
	Super::PostLogin(NewPlayer);
}

The PreLogin does not set an error message, which means approved.

But I do not understand why the function Login and PostLogin is never called ?

Do I have to check the username and the password in PreLogin ?

I have also a problem with the arguments LOGIN and PASSWORD documented in link text
How can I retrieve these two arguments since if I specify these two options in the the command line -login=aaa -password=xxx I don’t know where there are.

Txs for your help,
D

Hi . Why you think that ? “But I do not understand why the function Login and PostLogin is never called ?”. About “Do I have to check the username and the password in PreLogin ?” In my game yes, in PreLogin very easy accept or reject client. About password and login i use parameters in client “open 127.0.0.1:7777?password=userPsw?login=userLogin”. After your game mode start PreLogin all parammeters will be in “const FString& Options” use FString password = ParseOption(Options, TEXT(“password”)); and FString login= ParseOption(Options, TEXT(“login”));
example

     void AloginServer_GameMode::PreLogin(const FString& Options, const FString& Address, const TSharedPtr& UniqueId, FString& ErrorMessage)
{
     FString password = ParseOption(Options, TEXT("password "));
     FString login= ParseOption(Options, TEXT("login"));
}

I hope this helpfull.

1 Like

Hello Anatoliy,

Yes, I had to close this question. Finally I make it working. It was a miss understanding from my side.
Now it is working.

Txs.