This topic is locked
[SOLVED]

lookup field on login screen

2/28/2024 1:17:56 PM
PHPRunner General questions
milver author

Hello friends,
If anyone can help me, I will be very grateful.
I'm trying to create a "Multi Company" style system
So I would like to place the company on the login screen for the user to select before logging in:
To do this, I created a field in the users table and inserted it on the login screen:

img alt

So I generated the project, and my login screen was the same as the screen below, until this moment, everything was perfect, using and Event (BeforeLogin) to retrieve this value and make the necessary modifications to the tables I need.

img alt

However, after entering this field, it always gives an invalid login, as if it was taken into account to validate the login. By removing this field, login can be performed normally.

img alt

Could you give me more help?

admin 2/28/2024

My guess is that you need to perform the login validation manually in BeforeLogin event. More info:
https://xlinesoft.com/phprunner/docs/before_login.htm

Also, you can employ a better technique for multi-tenant ( SaaS ) applications:
https://xlinesoft.com/blog/2019/10/03/saas-application-design/

milver author 3/4/2024

Tks Admin:

Before Login:

if ($values['idevento'] == "") {

$message = "Informe o Evento!";
return false;

} else if (Security::checkUsernamePassword($username, $password, $fireEvents = true) == true) {

//Set the Selected Event in the user table

$SQL = "update usuarios set idevento = ".$values['idevento']." where email = '".$username."'" ;
DB::Exec($SQL);

// Log in

Security::loginAs($username);

} else {

$message = "Invalid Login!";
return false;

}