@@ -576,6 +576,17 @@ void USequenceAuthenticator::InitializeSequence(const FCredentials_BE& Credentia
576576
577577void USequenceAuthenticator::PlayFabLoginRPC (const FString& UsernameIn, const FString& PasswordIn, const TSuccessCallback<FString>& OnSuccess, const FFailureCallback& OnFailure)
578578{
579+ if (!USequenceAuthenticator::ValidateUsername (UsernameIn).IsEmpty ())
580+ {
581+ OnFailure (FSequenceError (InvalidArgument, USequenceAuthenticator::ValidateUsername (UsernameIn)));
582+ return ;
583+ }
584+ if (!USequenceAuthenticator::ValidatePassword (PasswordIn).IsEmpty ())
585+ {
586+ OnFailure (FSequenceError (InvalidArgument, USequenceAuthenticator::ValidatePassword (PasswordIn)));
587+ return ;
588+ }
589+
579590 const TFunction<void (FString)> OnSuccessResponse = [OnSuccess, OnFailure](const FString& Response)
580591 {
581592 if (const FPlayFabLoginUserResponse ParsedResponse = USequenceSupport::JSONStringToStruct<FPlayFabLoginUserResponse>(Response); ParsedResponse.IsValid ())
@@ -597,6 +608,22 @@ void USequenceAuthenticator::PlayFabLoginRPC(const FString& UsernameIn, const FS
597608
598609void USequenceAuthenticator::PlayFabNewAccountLoginRPC (const FString& UsernameIn, const FString& EmailIn, const FString& PasswordIn, const TSuccessCallback<FString>& OnSuccess, const FFailureCallback& OnFailure)
599610{
611+ if (!USequenceAuthenticator::ValidateUsername (UsernameIn).IsEmpty ())
612+ {
613+ OnFailure (FSequenceError (InvalidArgument, USequenceAuthenticator::ValidateUsername (UsernameIn)));
614+ return ;
615+ }
616+ if (!USequenceAuthenticator::ValidatePassword (PasswordIn).IsEmpty ())
617+ {
618+ OnFailure (FSequenceError (InvalidArgument, USequenceAuthenticator::ValidatePassword (PasswordIn)));
619+ return ;
620+ }
621+ if (!USequenceAuthenticator::ValidateEmail (EmailIn).IsEmpty ())
622+ {
623+ OnFailure (FSequenceError (InvalidArgument, USequenceAuthenticator::ValidateEmail (EmailIn)));
624+ return ;
625+ }
626+
600627 const TFunction<void (FString)> OnSuccessResponse = [OnSuccess, OnFailure](const FString& Response)
601628 {
602629 if (const FPlayFabRegisterUserResponse ParsedResponse = USequenceSupport::JSONStringToStruct<FPlayFabRegisterUserResponse>(Response); ParsedResponse.IsValid ())
@@ -639,6 +666,51 @@ void USequenceAuthenticator::PlayFabRPC(const FString& Url, const FString& Conte
639666 ->ProcessAndThen (OnSuccess, OnFailure);
640667}
641668
669+ FString USequenceAuthenticator::ValidateUsername (const FString& Username)
670+ {
671+ if (Username.IsEmpty ())
672+ {
673+ return " Username cannot be empty" ;
674+ }
675+ return " " ;
676+ }
677+
678+ FString USequenceAuthenticator::ValidateEmail (const FString& Email)
679+ {
680+ if (Email.IsEmpty ())
681+ {
682+ return " Email cannot be empty" ;
683+ }
684+
685+ int32 AtIndex;
686+
687+ if (!Email.FindChar (' @' , AtIndex) || AtIndex == 0 )
688+ {
689+ return TEXT (" Email is invalid, given " + Email);
690+ }
691+
692+ if (!Email.FindChar (' .' , AtIndex) || AtIndex == 0 )
693+ {
694+ return TEXT (" Email is invalid, given " + Email);
695+ }
696+
697+
698+ return " " ;
699+ }
700+
701+ FString USequenceAuthenticator::ValidatePassword (const FString& Password)
702+ {
703+ if (Password.IsEmpty ())
704+ {
705+ return " Password cannot be empty" ;
706+ }
707+ if (Password.Len () < 8 )
708+ {
709+ return " Password must be at least 8 characters long" ;
710+ }
711+ return " " ;
712+ }
713+
642714void USequenceAuthenticator::EmailLoginCode (const FString& CodeIn)
643715{
644716 if (this ->ReadAndResetIsFederating ())
@@ -769,7 +841,7 @@ void USequenceAuthenticator::FederatePlayFabNewAccount(const FString& UsernameIn
769841
770842 const FFailureCallback OnFailure = [this ](const FSequenceError& Error)
771843 {
772- UE_LOG (LogTemp, Error , TEXT (" Error Federating PlayFab Account: %s" ), *Error.Message );
844+ UE_LOG (LogTemp, Warning , TEXT (" Error Federating PlayFab Account: %s" ), *Error.Message );
773845 this ->CallFederateFailure (Error.Message );
774846 };
775847
@@ -787,7 +859,7 @@ void USequenceAuthenticator::FederatePlayFabLogin(const FString& UsernameIn, con
787859
788860 const FFailureCallback OnFederateFailure = [this ](const FSequenceError& Error)
789861 {
790- UE_LOG (LogTemp, Error , TEXT (" Error Federating PlayFab Account: %s" ), *Error.Message );
862+ UE_LOG (LogTemp, Warning , TEXT (" Error Federating PlayFab Account: %s" ), *Error.Message );
791863 this ->CallFederateFailure (Error.Message );
792864 };
793865
@@ -807,7 +879,7 @@ void USequenceAuthenticator::FederatePlayFabLogin(const FString& UsernameIn, con
807879
808880 const FFailureCallback OnFailure = [this ](const FSequenceError& Error)
809881 {
810- UE_LOG (LogTemp, Error , TEXT (" Error Federating PlayFab Account: %s" ), *Error.Message );
882+ UE_LOG (LogTemp, Warning , TEXT (" Error Federating PlayFab Account: %s" ), *Error.Message );
811883 this ->CallFederateFailure (Error.Message );
812884 };
813885
0 commit comments