Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Login script

Questions related to using nuBuilder Forte.
Locked
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

Login script

Unread post 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.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Login script

Unread post 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
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

Re: Login script

Unread post 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?
toms
Posts: 785
Joined: Sun Oct 14, 2018 11:25 am

Re: Login script

Unread post 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");
}
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Login script

Unread post by admin »

.
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

Re: Login script

Unread post by amit »

Thank you, as always, for your help!
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: Login script

Unread post by admin »

.
Locked