Mike I Posted November 22, 2019 Posted November 22, 2019 Hate to bump such an old thread, but has anyone figured out a way of going about this with version 4.4+?
Jibeji Posted November 22, 2019 Posted November 22, 2019 Hi, This works with the current release : if ((isset($_POST["token"], $_COOKIE["CSRFtoken"])) && ($_POST["token"] == $_COOKIE["CSRFtoken"])) { require_once($_SERVER['DOCUMENT_ROOT'].'/forums/init.php'); $IPSLogin = new \IPS\Login\Internal; $IPSLogin->init(); $member = \IPS\Member::load( $_POST['username'], 'name' ); if ( $member->member_id ) { if ( \IPS\Login\Handler::findMethod('IPS\Login\Handler\Standard')->authenticatePasswordForMember($member, \IPS\Request::i()->password ) ) { $device = \IPS\Member\Device::loadOrCreate($member); $device->updateAfterAuthentication( TRUE ); // TRUE is "Remember Me" echo 1; } else { echo 0; // Password incorrect } } }
Mike I Posted November 22, 2019 Posted November 22, 2019 7 hours ago, Jibeji said: Hi, This works with the current release : *snip* Hey, thanks for the reply. Unfortunately my script stops at $IPSLogin = new \IPS\Login\Internal; And here is the entire script for reference. <?php $path = ''; require_once $path . 'init.php'; $IPSLogin = new \IPS\Login\Internal; $IPSLogin->init(); $member = \IPS\Member::load( $_POST['username'], 'name' ); if ( $member->member_id ) { if ( \IPS\Login\Handler::findMethod('IPS\Login\Handler\Standard')->authenticatePasswordForMember($member, \IPS\Request::i()->password ) ) { $device = \IPS\Member\Device::loadOrCreate($member); $device->updateAfterAuthentication( TRUE ); // TRUE is "Remember Me" \IPS\Output::i()->json( array( "status" => "SUCCESS", "connect_id" => $member->member_id, ) ); } else { \IPS\Output::i()->json( // Password incorrect array( 'status' => 'FAILED', 'msg' => 'ACCOUNT_INVALID_PASSWORD', ) ); } } ?> I'm not much of a PHP guy, I was initially just looking for where IPS does its login code/logic and planned to rebuild it in C++, but had no luck finding it. Thanks.
Jibeji Posted November 22, 2019 Posted November 22, 2019 That probably means that this fails: require_once $path . 'init.php';
Mike I Posted November 22, 2019 Posted November 22, 2019 9 minutes ago, Jibeji said: That probably means that this fails: require_once $path . 'init.php'; Doesn't seem like it fails. I have the .php in the same directory as init.php. index.php just does require_once 'init.php'; and that doesn't throw any errors or anything either. Not sure why `$IPSLogin = new \IPS\Login\Internal;` is causing the script to stop.
Stuart Silvester Posted November 22, 2019 Posted November 22, 2019 `\IPS\Login\Internal` does not exist in 4.3 or newer. You don't need either of these lines $IPSLogin = new \IPS\Login\Internal; $IPSLogin->init();
Mike I Posted November 22, 2019 Posted November 22, 2019 41 minutes ago, Stuart Silvester said: `\IPS\Login\Internal` does not exist in 4.3 or newer. You don't need either of these lines $IPSLogin = new \IPS\Login\Internal; $IPSLogin->init(); Awesome, thanks. Got it working. Thanks @Jibeji, the rest of your code worked perfectly.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.