Page 1 of 1

nuBuilder external log in

Posted: Fri Feb 04, 2022 10:29 pm
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!

Re: nuBuilder external log in

Posted: Sat Feb 05, 2022 10:04 am
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..


Re: nuBuilder external log in

Posted: Wed Feb 23, 2022 4:37 pm
by kev1n
Hi,

I was wondering if you were able to resolve this.