We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

Log in User from external login page | Forum

Topic location: Forum home » Support » General Questions
Luca Orietti
Luca Orietti Apr 1 '19

Hi all,

I'm trying to make the following php code to work but it keeps me giving the same error: " Fatal error: Call to a member function isAuthenticated() on null in /web/htdocs/mysite.net/home/ow_core/auth.php on line 88"


Here's the code:


<?php
define('_OW_', true);

define('DS', DIRECTORY_SEPARATOR);

define('OW_DIR_ROOT', dirname(__FILE__) . DS);
require_once(OW_DIR_ROOT . 'ow_includes' . DS . 'init.php');
require_once(OW_DIR_ROOT . 'ow_system_plugins' . DS . 'base/classes/standard_auth.php');
require_once(OW_DIR_ROOT . 'ow_core' . DS . 'session.php');
require_once(OW_DIR_ROOT . 'ow_core' . DS . 'user.php');

OW::getSession()->start();

$username = 'test'; //forced username for test
$password = 'test'; //forced password for test


$result = OW::getUser()->authenticate(new BASE_CLASS_StandardAuth($username, $password));

if ( $result->isValid() )
{
    if ( isset($data['remember']) )
    {
        $loginCookie = $this->userService->saveLoginCookie(OW::getUser()->getId());

        setcookie('ow_login', $loginCookie->getCookie(), (time() + 86400 * 7), '/', null, null, true);
    }

}

session_regenerate_id();


header('Location:https://mysite.net/')
?>


Thanks in advace.

The Forum post is edited by Luca Orietti Apr 1 '19
Luca Orietti
Luca Orietti Apr 2 '19

Solved!

I missed the inizialisation of the Authenticator:


OW_Auth::getInstance()->setAuthenticator(new OW_SessionAuthenticator());


now it logs without problems.