userLoggingIn and userCustomValidate - no setFailureMessage support

Hi,

appears phpMaker has made changes to fix the userLoggingIn() issue, but now, userLoggingIn() and userCustomValidate, does not support $this->setFailureMessage().

anyone have a workaround to display messages easily enough?

You may use:

FlashBag()->set("failure", $msg);

thanks, this worked.

is there any way to force/append the new message to display? – the message doesn’t display unless the page is refreshed, the message it displays “login cancelled” is displayed after returning from the function set as false.

example

    public function userLoggingIn(string $userName, string $password): bool
    {
       if (!in_array($iso, $UserAllowedCountry)) {                               
         SendEmail_Security_Login_Alert($userName, "$iso", "$cn", "$region", "$city");
   WriteAuditLog($userName, $Language->phrase("AuditTrailLogin"), "$guest_ip", "$iso", "$cn", "", "DENY");                                                               
                                                
FlashBag()->set("failure", str_replace("%s", $cn, $Language->phrase("UnAuthorizedCountry")));
     return false;   
   }
    }

the above failure message is not displayed unless the page is refreshed, the “login cancelled” is displayed when returning from this function.

tried FlashBag()->add() – same outcome

thanks,
JS

Double check your code, especially that part.

It seems it will trigger an error, since you use $Language object variable, but you did not re-declare it inside that server event.

That’s why probably the first attempt your failure message does not show up, and it will show up in the next attempt after you refresh the page.

In addition, there are some another variables in that event that never declared, that also will trigger errors.

Please correct me if I’m wrong.

this has been fixed by phpMaker, this was an issue within the templates.
the userLoggingIn() even has been moved to: AuthenticationEventSubscriber.php

messages can be displayed with:
throw new BadCredentialsException($Language->phrase(“invaliduidpwd”));