Page 1 of 1

Login script

Posted: Tue Jun 05, 2018 8:39 pm
by amit
How do I execute a PHP script right after a user has logged in? The script should only be executed once and the condition should be that an error message is displayed if a user logs in and the IP address is not in a white list. Thank you.

Re: Login script

Posted: Wed Jun 13, 2018 4:12 am
by admin
amit,

Firstly create a Launch Form for each of the Access Levels you would like to check.

https://wiki.nubuilder.cloud/ ... .php/Forms

And then apply the Launch Form to that Access Level.

https://wiki.nubuilder.cloud/ ... cess_Level

Then in the Custom Code Tab of the Launch Form's properties, you can add add PHP, by Clicking on the Before Edit Button.

Then you can use a Hash Cookie to help get the User's information.

https://wiki.nubuilder.cloud/ ... sh_Cookies

Steven

Re: Login script

Posted: Sun Jun 17, 2018 11:52 am
by amit
Thanks, this is what I have so far:

$remoteAddr = $_SERVER['REMOTE_ADDR'];
$ipWhiteList = array("116.100.119.120", "199.36.152.45",);

if (! in_array($remoteAddr, $ipWhiteList)) {
Logout the user here
}


If the IP is not in the whitelist, the user has to be logged out as he is not allowed to access nubuilder.

How can I do this?

Re: Login script

Posted: Wed Jun 20, 2018 10:26 am
by toms
Try this:

Code: Select all

$remoteAddr = $_SERVER['REMOTE_ADDR'];
$ipWhiteList = array("116.100.119.120", "199.36.152.45",);

if (! in_array($remoteAddr, $ipWhiteList)) {
     nuDisplayError("Invalid Login");
}

Re: Login script

Posted: Wed Jun 27, 2018 3:15 am
by admin
.

Re: Login script

Posted: Fri Jul 06, 2018 7:54 pm
by amit
Thank you, as always, for your help!

Re: Login script

Posted: Fri Jul 06, 2018 8:05 pm
by admin
.