XF 2.0 Access Xenforo functions through OAuth2 from second host ?

Artur1339

Member
Hey,

I am trying to use Xenforo for my authentication in lumen ( laravel ), because I have a client-side anticheat and warehouse for my GTA V Roleplay server., where the user logs in with the Xenforo account.
Basically, I have a second page, powered by lumen as a restful and VueJs as the frontend, and from there the user can manage in-game auctions like selling cars, property etc.
Therefore I have to make sure that the user is logged in correctly and access some stuff like email, name, account status like is he banned or not.
So I was wondering what would be the best way of integrating it? I already got the login working but for this, I have this basic implementation.
PHP:
class UserController extends Controller
{
    private function bootstrapXenforo()
    {
        $fileDir = __DIR__ . '/../../../../board';
        require($fileDir . '/src/XF.php');
        \XF::start($fileDir);
    }
    private function tryLoginXenforoUser(Request $request)
    {
        $this->bootstrapXenforo();
        $xf_app = \XF::setupApp('XF\App');
        $ip = $xf_app->request->getIp();
        $loginService = $xf_app->service('XF:User\Login', $request->input('username'), $ip);
        $error = '0';
        $userValidate =  $loginService->validate($request->input('password'), $error);
        if(!$userValidate)
        {
            return response()->json([
                'status' => 'login_error',
                'error' => $error
            ]);
        }else if($userValidate->is_banned)
        {
            return response()->json([
                'status' => 'login_error',
                'error' => 'This account is banned'
            ]);
        }

        return $userValidate;
    }
}

I was wondering if there is a kind of auth api like OAuth2 for Xenforo? So I could access this data with the Xenforo installation on a separate host?

Regards Artur

PS: I am not a pro, so I am sorry if somethings are messy.
 
Top Bottom