Welcome to the nuBuilder Forums!

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

nuBuilder external log in

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
PoppingMonks
Posts: 3
Joined: Tue Dec 21, 2021 4:50 pm
Has thanked: 1 time

nuBuilder external log in

Unread post by PoppingMonks »

Hi nuBuilders,

I've built a login form on my web's root page, nuBuilder is installed as a child folder. I want to pass the credentials from root to nuBuilder, but don't want the user name and password hanging on the url.

Is there a good method or any way to do this? I tried session variables but didn't have any luck.

Thanks!
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: nuBuilder external log in

Unread post by kev1n »

Hi,

Looking at nuLoginRequest() in index.php, a post request is done with Ajax when logging in.

In PHP, you can use cURL to send a HTTP POST:
https://www.wdb24.com/php-curl-post-req ... arameters/

The JS then calls nuForm() to open a form:

Code: Select all

nuForm(data.form_id, data.record_id, data.filter, data.search);
In theory, after executing curl, retrieve its response data, evaluate it and run nuForm()

The request then looks something like this:
(The code didn't return a response when I tested it, obviously I'm missing something here)

Code: Select all

$ch = curl_init( 'core/nuapi.php' );

$w = [
	'call_type'			=> 'login', 
	'username'			=> 'globeadmin',
	'password'			=> 'nu',
	'login_form_id'		=> '',
	'login_record_id'	=> ''
];

$pst = json_encode( array( "nuSTATE"=> $w ) );

curl_setopt( $ch, CURLOPT_POSTFIELDS, $post );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );

$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "<pre>$result</pre>";
echo 'HTTP code: ' . $httpcode;

// to-do: evaluate response and run nuForm() etc..

kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: nuBuilder external log in

Unread post by kev1n »

Hi,

I was wondering if you were able to resolve this.
Post Reply